Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
column-utils.h
Go to the documentation of this file.
1
11#pragma once
12#include "packet_info.h"
13#include "ws_symbol_export.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif /* __cplusplus */
18
19#define COL_MAX_LEN 2048
20#define COL_MAX_INFO_LEN 4096
21
22/* A regex to split possibly multifield custom columns into components
23 *
24 * Split on operator "||" (with optional space around it) and on "or"
25 * (which must have space around it to avoid matching in the middle of
26 * a word, field in the "synphasor" protocol, etc. This is somewhat too
27 * strict, as "or" adjacent to parentheses ought to be fine so long
28 * as the filter matches the grammar, like "(tcp.port)or(udp.port)",
29 * but that's the cost of using regex instead of the real parser.)
30 * Also split on space at the beginning or end of the expression (in
31 * lieu of always stripping whitespace at the beginning and end, but it
32 * does mean that we have to ignore any empty tokens in the result.)
33 *
34 * Use negative lookahead to avoid matching "||" or "or" that are contained
35 * within parentheses. Don't match if a close parenthesis comes before an
36 * open parenthesis. The regex doesn't help with unmatched parentheses, but
37 * such an expression already won't satisfy the grammar and won't compile.
38 */
39#define COL_CUSTOM_PRIME_REGEX "(?:^ *| *\\|\\| *| +or +| *$)(?![^(]*\\))"
40
41struct epan_dissect;
42
47struct epan_column_info;
48typedef struct epan_column_info column_info;
49
59enum {
111
119WS_DLL_PUBLIC bool col_get_writable(column_info *cinfo, const int col);
120
128WS_DLL_PUBLIC void col_set_writable(column_info *cinfo, const int col, const bool writable);
129
140WS_DLL_PUBLIC void col_set_fence(column_info *cinfo, const int col);
141
151WS_DLL_PUBLIC void col_clear_fence(column_info *cinfo, const int col);
152
161WS_DLL_PUBLIC const char *col_get_text(column_info *cinfo, const int col);
162
169WS_DLL_PUBLIC void col_clear(column_info *cinfo, const int col);
170
184WS_DLL_PUBLIC void col_set_str(column_info *cinfo, const int col, const char * str);
185
195WS_DLL_PUBLIC void col_add_str(column_info *cinfo, const int col, const char *str);
196
197/* terminator argument for col_add_lstr() function */
198#define COL_ADD_LSTR_TERMINATOR (const char *) -1
199
207WS_DLL_PUBLIC void col_add_lstr(column_info *cinfo, const int el, const char *str, ...);
208
221WS_DLL_PUBLIC void col_add_fstr(column_info *cinfo, const int col, const char *format, ...)
222 G_GNUC_PRINTF(3, 4);
223
233WS_DLL_PUBLIC void col_append_str(column_info *cinfo, const int col, const char *str);
234
244WS_DLL_PUBLIC void col_append_str_uint(column_info *cinfo, const int col, const char *abbrev, uint32_t val, const char *sep);
245
255WS_DLL_PUBLIC void col_append_ports(column_info *cinfo, const int col, port_type typ, uint16_t src, uint16_t dst);
256
266WS_DLL_PUBLIC void col_append_frame_number(packet_info *pinfo, const int col, const char *fmt_str, unsigned frame_num);
267
273WS_DLL_PUBLIC void col_append_lstr(column_info *cinfo, const int el, const char *str, ...);
274
287WS_DLL_PUBLIC void col_append_fstr(column_info *cinfo, const int col, const char *format, ...)
288 G_GNUC_PRINTF(3, 4);
289
300WS_DLL_PUBLIC void col_prepend_fstr(column_info *cinfo, const int col, const char *format, ...)
301 G_GNUC_PRINTF(3, 4);
302
315WS_DLL_PUBLIC void col_prepend_fence_fstr(column_info *cinfo, const int col, const char *format, ...)
316 G_GNUC_PRINTF(3, 4);
317
330WS_DLL_PUBLIC void col_append_sep_str(column_info *cinfo, const int col, const char *sep,
331 const char *str);
332
346WS_DLL_PUBLIC void col_append_sep_fstr(column_info *cinfo, const int col, const char *sep,
347 const char *format, ...)
348 G_GNUC_PRINTF(4, 5);
349
361WS_DLL_PUBLIC void col_set_time(column_info *cinfo, const int col,
362 const nstime_t *ts, const char *fieldname);
363
371WS_DLL_PUBLIC void set_fd_time(const struct epan_session *epan, frame_data *fd, char *buf);
372
373#ifdef __cplusplus
374}
375#endif /* __cplusplus */
port_type
Transport-layer port number types recognized by Wireshark.
Definition address.h:425
WS_DLL_PUBLIC const char * col_get_text(column_info *cinfo, const int col)
Gets the text of a column element.
Definition column-utils.c:255
WS_DLL_PUBLIC void col_clear_fence(column_info *cinfo, const int col)
Clears a fence for the current column content.
Definition column-utils.c:237
WS_DLL_PUBLIC void col_append_ports(column_info *cinfo, const int col, port_type typ, uint16_t src, uint16_t dst)
Append a transport port pair to a column element, the text will be copied.
Definition column-utils.c:523
WS_DLL_PUBLIC void col_set_fence(column_info *cinfo, const int col)
Sets a fence for the current column content, so this content won't be affected by further col_....
Definition column-utils.c:219
WS_DLL_PUBLIC void col_add_str(column_info *cinfo, const int col, const char *str)
Add (replace) the text of a column element, the text will be formatted and copied.
Definition column-utils.c:744
WS_DLL_PUBLIC void col_append_str(column_info *cinfo, const int col, const char *str)
Append the given text to a column element, the text will be formatted and copied.
Definition column-utils.c:953
WS_DLL_PUBLIC void col_set_time(column_info *cinfo, const int col, const nstime_t *ts, const char *fieldname)
Set the given (relative) time to a column element.
Definition column-utils.c:1774
WS_DLL_PUBLIC void set_fd_time(const struct epan_session *epan, frame_data *fd, char *buf)
Set the time for a frame data structure.
WS_DLL_PUBLIC void col_set_writable(column_info *cinfo, const int col, const bool writable)
Set writability for either all columns or a specific column.
Definition column-utils.c:191
WS_DLL_PUBLIC void col_add_fstr(column_info *cinfo, const int col, const char *format,...)
Add (replace) the text of a column element, the text will be formatted and copied.
Definition column-utils.c:872
WS_DLL_PUBLIC void col_append_sep_str(column_info *cinfo, const int col, const char *sep, const char *str)
Append the given text (prepended by a separator) to a column element.
Definition column-utils.c:962
WS_DLL_PUBLIC void col_append_frame_number(packet_info *pinfo, const int col, const char *fmt_str, unsigned frame_num)
Append a frame number and signal that we have updated column information.
Definition column-utils.c:536
WS_DLL_PUBLIC void col_clear(column_info *cinfo, const int col)
Clears the text of a column element.
Definition column-utils.c:282
WS_DLL_PUBLIC void col_prepend_fence_fstr(column_info *cinfo, const int col, const char *format,...)
Prepend the given text to a column element, the text will be formatted and copied.
Definition column-utils.c:686
WS_DLL_PUBLIC void col_append_str_uint(column_info *cinfo, const int col, const char *abbrev, uint32_t val, const char *sep)
Append <abbrev>=<val> to a column element, the text will be copied.
Definition column-utils.c:498
WS_DLL_PUBLIC void col_prepend_fstr(column_info *cinfo, const int col, const char *format,...)
Prepend the given text to a column element, the text will be formatted and copied.
Definition column-utils.c:629
WS_DLL_PUBLIC bool col_get_writable(column_info *cinfo, const int col)
Check if a column is writable.
Definition column-utils.c:166
WS_DLL_PUBLIC void col_append_lstr(column_info *cinfo, const int el, const char *str,...)
Append the given strings (terminated by COL_ADD_LSTR_TERMINATOR) to a column element,...
Definition column-utils.c:454
WS_DLL_PUBLIC void col_append_fstr(column_info *cinfo, const int col, const char *format,...)
Append the given text to a column element, the text will be formatted and copied.
Definition column-utils.c:595
WS_DLL_PUBLIC void col_append_sep_fstr(column_info *cinfo, const int col, const char *sep, const char *format,...)
Append the given text (prepended by a separator) to a column element.
Definition column-utils.c:611
WS_DLL_PUBLIC void col_set_str(column_info *cinfo, const int col, const char *str)
Set (replace) the text of a column element, the text won't be formatted or copied.
Definition column-utils.c:782
WS_DLL_PUBLIC void col_add_lstr(column_info *cinfo, const int el, const char *str,...)
Add (replace) the text of a column element using a printf-like format string.
Definition column-utils.c:821
@ COL_ABS_TIME
Definition column-utils.h:62
@ COL_RES_DST
Definition column-utils.h:67
@ COL_NUMBER
Definition column-utils.h:92
@ COL_UNRES_NET_DST
Definition column-utils.h:87
@ COL_RES_SRC
Definition column-utils.h:100
@ COL_DEF_NET_SRC
Definition column-utils.h:91
@ COL_INFO
Definition column-utils.h:85
@ COL_DEF_DL_SRC
Definition column-utils.h:77
@ COL_UNRES_DL_SRC
Definition column-utils.h:81
@ COL_TX_RATE
Definition column-utils.h:83
@ COL_RES_DL_DST
Definition column-utils.h:78
@ COL_DEF_DST_PORT
Definition column-utils.h:72
@ COL_CUSTOM
Definition column-utils.h:64
@ COL_ABS_YMD_TIME
Definition column-utils.h:60
@ COL_RES_DL_SRC
Definition column-utils.h:80
@ COL_DELTA_TIME_DIS
Definition column-utils.h:66
@ COL_FREQ_CHAN
Definition column-utils.h:75
@ COL_DEF_DST
Definition column-utils.h:71
@ COL_RSSI
Definition column-utils.h:82
@ COL_DELTA_TIME
Definition column-utils.h:65
@ COL_CLS_TIME
Definition column-utils.h:107
@ COL_UTC_YMD_TIME
Definition column-utils.h:104
@ COL_UNRES_SRC_PORT
Definition column-utils.h:103
@ COL_USER_NAME
Definition column-utils.h:108
@ COL_PROTOCOL
Definition column-utils.h:95
@ COL_IF_DIR
Definition column-utils.h:74
@ COL_RES_NET_DST
Definition column-utils.h:86
@ COL_REL_CAP_TIME
Definition column-utils.h:97
@ COL_UNRES_DST_PORT
Definition column-utils.h:70
@ COL_UNRES_SRC
Definition column-utils.h:101
@ COL_DEF_SRC_PORT
Definition column-utils.h:99
@ COL_RES_NET_SRC
Definition column-utils.h:88
@ COL_DEF_SRC
Definition column-utils.h:98
@ COL_UNRES_DST
Definition column-utils.h:68
@ COL_UTC_TIME
Definition column-utils.h:106
@ NUM_COL_FMTS
Definition column-utils.h:109
@ COL_RES_SRC_PORT
Definition column-utils.h:102
@ COL_UNRES_DL_DST
Definition column-utils.h:79
@ COL_REL_TIME
Definition column-utils.h:96
@ COL_DEF_NET_DST
Definition column-utils.h:90
@ COL_UNRES_NET_SRC
Definition column-utils.h:89
@ COL_DSCP_VALUE
Definition column-utils.h:84
@ COL_NUMBER_DIS
Definition column-utils.h:93
@ COL_UTC_YDOY_TIME
Definition column-utils.h:105
@ COL_PACKET_LENGTH
Definition column-utils.h:94
@ COL_ABS_YDOY_TIME
Definition column-utils.h:61
@ COL_DEF_DL_DST
Definition column-utils.h:76
@ COL_EXPERT
Definition column-utils.h:73
@ COL_CUMULATIVE_BYTES
Definition column-utils.h:63
@ COL_RES_DST_PORT
Definition column-utils.h:69
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.
Represents the metadata and indexing information for a single captured frame.
Definition packet_info.h:43
Definition column-info.h:59
bool writable
Definition column-info.h:66
Holds all state for the dissection of a single byte array, including session, buffer,...
Definition epan_dissect.h:28
Definition epan.c:532
Definition nstime.h:26