Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
tag_rules.h
Go to the documentation of this file.
1/* tag_rules.h
2 * Definitions for tagging rules
3 * Copyright 2026, Mark Stout <[email protected]>
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <[email protected]>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11#pragma once
12#include <glib.h>
13
14#include "ws_symbol_export.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20struct epan_dfilter;
21struct epan_dissect;
22
23#define TAGRULES_FILE_NAME "tagrules.jsonc"
24
28
37
49
53typedef struct _tag_rule {
54 char *rule_name; /* Name — also the frame.tag value for filtering */
55 char *filter_text; /* Display filter expression */
56 char *tag_content; /* Visual content shown in COL_TAG column (emoji / text) */
57 char *tag_url; /* Optional URL opened when cell is clicked */
58 char *comment; /* Optional reference comment */
59 bool disabled;
60 struct epan_dfilter *c_tagfilter; /* compiled dfilter, NULL if disabled or invalid */
62
69typedef void (*tag_rule_add_cb_func)(tag_rule_t *rule, void *user_data);
70
76WS_DLL_PUBLIC void tag_rules_init(void);
77
83WS_DLL_PUBLIC void tag_rules_reload(void);
84
90WS_DLL_PUBLIC bool tag_rules_write(void);
91
101WS_DLL_PUBLIC tag_rule_t *tag_rule_new(const char *name, const char *filter,
102 const char *tag_content,
103 const char *tag_url,
104 const char *comment);
105
111WS_DLL_PUBLIC void tag_rule_delete(tag_rule_t *rule);
112
121WS_DLL_PUBLIC void tag_rules_clone(tag_rule_add_cb_func cb, void *user_data);
122
130WS_DLL_PUBLIC void tag_rules_apply(GSList *new_list);
131
137WS_DLL_PUBLIC const GSList *tag_rules_get_list(void);
138
147WS_DLL_PUBLIC void tag_rules_prime_edt(struct epan_dissect *edt);
148
150WS_DLL_PUBLIC bool tag_rules_used(void);
151
155WS_DLL_PUBLIC tag_prefs_t tag_rules_get_prefs(void);
156
160WS_DLL_PUBLIC void tag_rules_set_prefs(const tag_prefs_t *prefs);
161
169WS_DLL_PUBLIC GSList *tag_rules_read_path(const char *path, char **err_msg);
170
182WS_DLL_PUBLIC bool tag_rules_write_path(GSList *list, const char *path,
183 const tag_prefs_t *prefs,
184 char **err_msg);
185
186
195WS_DLL_PUBLIC bool tag_rules_export_list(GSList *list, const char *path, char **err_msg);
196
202WS_DLL_PUBLIC void tag_rule_list_free(GSList *list);
203
204#ifdef __cplusplus
205}
206#endif /* __cplusplus */
207
208/*
209 * Editor modelines - https://www.wireshark.org/tools/modelines.html
210 *
211 * Local variables:
212 * c-basic-offset: 4
213 * tab-width: 8
214 * indent-tabs-mode: nil
215 * End:
216 *
217 * vi: set shiftwidth=4 tabstop=8 expandtab:
218 * :indentSize=4:tabSize=8:noTabs=true:
219 */
Display preferences for the tagging subsystem.
Definition tag_rules.h:44
tag_link_click_mode_t link_click
Definition tag_rules.h:47
char separator
Definition tag_rules.h:45
int emoji_size
Definition tag_rules.h:46
Data for a single tagging rule.
Definition tag_rules.h:53
The compiled display filter object passed back to the user.
Definition dfilter-int.h:46
Holds all state for the dissection of a single byte array, including session, buffer,...
Definition epan_dissect.h:28
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.
Definition tag_rules.c:443
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).
Definition tag_rules.c:85
tag_link_click_mode_t
Controls how a tag link is activated in the packet list.
Definition tag_rules.h:32
@ TAG_LINK_CLICK_NONE
Definition tag_rules.h:35
@ TAG_LINK_CLICK_SINGLE
Definition tag_rules.h:33
@ TAG_LINK_CLICK_CTRL
Definition tag_rules.h:34
WS_DLL_PUBLIC tag_prefs_t tag_rules_get_prefs(void)
Get the current display preferences.
Definition tag_rules.c:62
WS_DLL_PUBLIC void tag_rule_delete(tag_rule_t *rule)
Delete a single tag rule and free all its memory.
Definition tag_rules.c:103
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.
Definition tag_rules.c:419
struct _tag_rule tag_rule_t
Data for a single tagging rule.
WS_DLL_PUBLIC const GSList * tag_rules_get_list(void)
Return the currently active tag rule list.
Definition tag_rules.c:530
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.
Definition tag_rules.c:537
WS_DLL_PUBLIC void tag_rules_set_prefs(const tag_prefs_t *prefs)
Set the display preferences (does not write to disk).
Definition tag_rules.c:74
WS_DLL_PUBLIC void tag_rules_prime_edt(struct epan_dissect *edt)
Prime an epan_dissect_t with all compiled tag rule filters.
Definition tag_rules.c:558
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).
Definition tag_rules.c:552
struct _tag_prefs tag_prefs_t
Display preferences for the tagging subsystem.
WS_DLL_PUBLIC void tag_rules_clone(tag_rule_add_cb_func cb, void *user_data)
Clone the currently active tag rule list.
Definition tag_rules.c:487
WS_DLL_PUBLIC void tag_rules_apply(GSList *new_list)
Apply a new tag rule list (called when the dialog OK is pressed).
Definition tag_rules.c:503
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).
Definition tag_rules.h:69
WS_DLL_PUBLIC bool tag_rules_write(void)
Write tag rules to the active profile's tagrules.jsonc file.
Definition tag_rules.c:459
WS_DLL_PUBLIC void tag_rules_init(void)
Initialize the tag rules subsystem (read from file).
Definition tag_rules.c:400
WS_DLL_PUBLIC bool tag_rules_used(void)
Definition tag_rules.c:68
WS_DLL_PUBLIC void tag_rules_reload(void)
Reload the tag rules from disk.
Definition tag_rules.c:413