2 * Definitions for column utility structures and routines
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __COLUMN_UTILS_H__
26 #define __COLUMN_UTILS_H__
30 #include "column_info.h"
31 #include "packet_info.h"
32 #include <epan/epan.h>
36 #endif /* __cplusplus */
39 * Helper routines for column utility structures and routines.
42 /** Allocate all the data structures for constructing column data, given
43 * the number of columns.
45 * Internal, don't use this in dissectors!
47 extern void col_setup(column_info *cinfo, const gint num_cols);
49 /** Initialize the data structures for constructing column data.
51 * Internal, don't use this in dissectors!
53 extern void col_init(column_info *cinfo);
55 /** Fill in all columns of the given packet which are based on values from frame_data.
57 * Internal, don't use this in dissectors!
59 extern void col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, gboolean const fill_col_exprs);
61 /** Fill in all columns of the given packet.
63 * Internal, don't use this in dissectors!
65 extern void col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fill_fd_colums);
67 /** Fill in columns if we got an error reading the packet.
68 * We set most columns to "???", and set the Info column to an error
71 * Internal, don't use this in dissectors!
73 extern void col_fill_in_error(column_info *cinfo, frame_data *fdata, const gboolean fill_col_exprs, const gboolean fill_fd_colums);
75 /* Utility routines used by packet*.c */
77 /** Are the columns writable?
79 * @param cinfo the current packet row
80 * @return TRUE if it's writable, FALSE if not
82 extern gboolean col_get_writable(column_info *cinfo);
84 /** Set the columns writable.
86 * @param cinfo the current packet row
87 * @param writable TRUE if it's writable, FALSE if not
89 extern void col_set_writable(column_info *cinfo, const gboolean writable);
92 * Checks if the given column can be filled with data.
94 * @param cinfo the current packet row
95 * @param col the column to use, e.g. COL_INFO
97 * @deprecated Not needed in new code the check is done in
98 * in the column function calls.
100 extern gint check_col(column_info *cinfo, const gint col);
102 /** Sets a fence for the current column content,
103 * so this content won't be affected by further col_... function calls.
105 * This can be useful if a protocol is more than once in a single packet,
106 * e.g. multiple HTTP calls in a single TCP packet.
108 * @param cinfo the current packet row
109 * @param col the column to use, e.g. COL_INFO
111 extern void col_set_fence(column_info *cinfo, const gint col);
113 /** Clears the text of a column element.
115 * @param cinfo the current packet row
116 * @param col the column to use, e.g. COL_INFO
118 extern void col_clear(column_info *cinfo, const gint col);
120 /** Set (replace) the text of a column element, the text won't be copied.
122 * Usually used to set const strings!
124 * @param cinfo the current packet row
125 * @param col the column to use, e.g. COL_INFO
126 * @param str the string to set
128 extern void col_set_str(column_info *cinfo, const gint col, const gchar * str);
130 /** Add (replace) the text of a column element, the text will be copied.
132 * @param cinfo the current packet row
133 * @param col the column to use, e.g. COL_INFO
134 * @param str the string to add
136 extern void col_add_str(column_info *cinfo, const gint col, const gchar *str);
138 /** Add (replace) the text of a column element, the text will be formatted and copied.
140 * Same function as col_add_str() but using a printf-like format string.
142 * @param cinfo the current packet row
143 * @param col the column to use, e.g. COL_INFO
144 * @param format the format string
145 * @param ... the variable number of parameters
147 extern void col_add_fstr(column_info *cinfo, const gint col, const gchar *format, ...)
150 /** For internal Wireshark use only. Not to be called from dissectors. */
151 void col_custom_set_edt(epan_dissect_t *edt, column_info *cinfo);
153 /** For internal Wireshark use only. Not to be called from dissectors. */
154 void col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo);
156 /** For internal Wireshark use only. Not to be called from dissectors. */
157 gboolean have_custom_cols(column_info *cinfo);
158 /** For internal Wireshark use only. Not to be called from dissectors. */
159 gboolean col_has_time_fmt(column_info *cinfo, const gint col);
160 /** For internal Wireshark use only. Not to be called from dissectors. */
161 gboolean col_based_on_frame_data(column_info *cinfo, const gint col);
163 /** Append the given text to a column element, the text will be copied.
165 * @param cinfo the current packet row
166 * @param col the column to use, e.g. COL_INFO
167 * @param str the string to append
169 extern void col_append_str(column_info *cinfo, const gint col, const gchar *str);
171 /** Append the given text to a column element, the text will be formatted and copied.
173 * Same function as col_append_str() but using a printf-like format string.
175 * @param cinfo the current packet row
176 * @param col the column to use, e.g. COL_INFO
177 * @param format the format string
178 * @param ... the variable number of parameters
180 extern void col_append_fstr(column_info *cinfo, const gint col, const gchar *format, ...)
183 /** Prepend the given text to a column element, the text will be formatted and copied.
185 * @param cinfo the current packet row
186 * @param col the column to use, e.g. COL_INFO
187 * @param format the format string
188 * @param ... the variable number of parameters
190 extern void col_prepend_fstr(column_info *cinfo, const gint col, const gchar *format, ...)
193 /**Prepend the given text to a column element, the text will be formatted and copied.
194 * This function is similar to col_prepend_fstr() but this function will
195 * unconditionally set a fence to the end of the prepended data even if there
196 * were no fence before.
197 * The col_prepend_fstr() will only prepend the data before the fence IF
198 * there is already a fence created. This function will create a fence in case
199 * it does not yet exist.
201 extern void col_prepend_fence_fstr(column_info *cinfo, const gint col, const gchar *format, ...)
204 /** Append the given text (prepended by a separator) to a column element.
206 * Much like col_append_str() but will prepend the given separator if the column isn't empty.
208 * @param cinfo the current packet row
209 * @param col the column to use, e.g. COL_INFO
210 * @param sep the separator string or NULL for default: ", "
211 * @param str the string to append
213 extern void col_append_sep_str(column_info *cinfo, const gint col, const gchar *sep,
216 /** Append the given text (prepended by a separator) to a column element.
218 * Much like col_append_fstr() but will prepend the given separator if the column isn't empty.
220 * @param cinfo the current packet row
221 * @param col the column to use, e.g. COL_INFO
222 * @param sep the separator string or NULL for default: ", "
223 * @param format the format string
224 * @param ... the variable number of parameters
226 extern void col_append_sep_fstr(column_info *cinfo, const gint col, const gchar *sep,
227 const gchar *format, ...)
230 /** Set the given (relative) time to a column element.
232 * Used by multiple dissectors to set the time in the column
233 * COL_DELTA_CONV_TIME
235 * @param cinfo the current packet row
236 * @param col the column to use, e.g. COL_INFO
237 * @param ts the time to set in the column
238 * @param fieldname the fieldname to use for creating a filter (when
239 * applying/preparing/copying as filter)
241 extern void col_set_time(column_info *cinfo, const int col,
242 const nstime_t *ts, char *fieldname);
244 extern void set_fd_time(frame_data *fd, gchar *buf);
248 #endif /* __cplusplus */
250 #endif /* __COLUMN_UTILS_H__ */