2 * Definitions for file structures and routines
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #include "packet-range.h"
29 #include "wiretap/wtap.h"
30 #include <epan/dfilter/dfilter.h>
33 #include <epan/epan.h>
37 /** Return values from functions that read capture files. */
39 CF_OK, /**< operation succeeded */
40 CF_ERROR /**< operation got an error (function may provide err with details) */
44 CF_READ_OK, /**< operation succeeded */
45 CF_READ_ERROR, /**< operation got an error (function may provide err with details) */
46 CF_READ_ABORTED /**< operation aborted by user */
49 /** Return values from functions that print sets of packets. */
51 CF_PRINT_OK, /**< operation succeeded */
52 CF_PRINT_OPEN_ERROR, /**< print operation failed while opening printer */
53 CF_PRINT_WRITE_ERROR /**< print operation failed while writing to the printer */
57 * Open a capture file.
59 * @param cf the capture file to be opened
60 * @param fname the filename to be opened
61 * @param is_tempfile is this a temporary file?
62 * @return one of cf_status_t
64 cf_status_t cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err);
67 * Close a capture file.
69 * @param cf the capture file to be closed
71 void cf_close(capture_file *cf);
74 * Reload a capture file.
76 * @param cf the capture file to be reloaded
78 void cf_reload(capture_file *cf);
81 * Read all packets of a capture file into the internal structures.
83 * @param cf the capture file to be read
84 * @return one of cf_read_status_t
86 cf_read_status_t cf_read(capture_file *cf);
89 * Start reading from the end of a capture file.
90 * This is used in "Update list of packets in Real-Time".
92 * @param cf the capture file to be read from
93 * @param fname the filename to be read from
94 * @param is_tempfile is this a temporary file?
95 * @param err the error code, if an error had occured
96 * @return one of cf_status_t
98 cf_status_t cf_start_tail(capture_file *cf, const char *fname, gboolean is_tempfile, int *err);
101 * Read packets from the "end" of a capture file.
103 * @param cf the capture file to be read from
104 * @param to_read the number of packets to read
105 * @param err the error code, if an error had occured
106 * @return one of cf_read_status_t
108 cf_read_status_t cf_continue_tail(capture_file *cf, int to_read, int *err);
111 * Finish reading from "end" of a capture file.
113 * @param cf the capture file to be read from
114 * @param err the error code, if an error had occured
115 * @return one of cf_read_status_t
117 cf_read_status_t cf_finish_tail(capture_file *cf, int *err);
120 * Save a capture file (or a range of it).
122 * @param cf the capture file to save to
123 * @param fname the filename to save to
124 * @param range the range of packets to save
125 * @param save_format the format of the file to save (libpcap, ...)
126 * @return one of cf_status_t
128 cf_status_t cf_save(capture_file * cf, const char *fname, packet_range_t *range, guint save_format);
131 * Get a displayable name of the capture file.
133 * @param cf the capture file
134 * @return the displayable name (don't have to be g_free'd)
136 const gchar *cf_get_display_name(capture_file *cf);
139 * Get the number of packets in the capture file.
141 * @param cf the capture file
142 * @return the number of packets in the capture file
144 int cf_packet_count(capture_file *cf);
147 * Is this capture file a temporary file?
149 * @param cf the capture file
150 * @return TRUE if it's a temporary file, FALSE otherwise
152 gboolean cf_is_tempfile(capture_file *cf);
155 * Get the interface name to capture from.
157 * @param cf the capture file
158 * @return the interface name (don't have to be g_free'd)
160 gchar *cf_get_iface(capture_file *cf);
163 * Get the capture filter of this capture file.
165 * @param cf the capture file
166 * @return the capture filter (don't have to be g_free'd)
168 gchar *cf_get_cfilter(capture_file *cf);
171 * Set flag, if the number of packet drops while capturing are known or not.
173 * @param cf the capture file
174 * @param drops_known TRUE if the number of packet drops are known, FALSE otherwise
176 void cf_set_drops_known(capture_file *cf, gboolean drops_known);
179 * Set the number of packet drops while capturing.
181 * @param cf the capture file
182 * @param drops the number of packet drops occured while capturing
184 void cf_set_drops(capture_file *cf, guint32 drops);
187 * Set the read filter.
188 * @todo this shouldn't be required, remove it somehow
190 * @param cf the capture file
191 * @param rfcode the readfilter
193 void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode);
196 * "Display Filter" packets in the capture file.
198 * @param cf the capture file
199 * @param dfilter the display filter
200 * @param force TRUE if do in any case, FALSE only if dfilter changed
201 * @return one of cf_status_t
203 cf_status_t cf_filter_packets(capture_file *cf, gchar *dfilter, gboolean force);
206 * At least one "Refence Time" flag has changed, rescan all packets.
208 * @param cf the capture file
210 void cf_reftime_packets(capture_file *cf);
213 * At least one "Refence Time" flag has changed, rescan all packets.
215 * @param cf the capture file
217 void cf_colorize_packets(capture_file *cf);
220 * "Something" has changed, rescan all packets.
222 * @param cf the capture file
224 void cf_redissect_packets(capture_file *cf);
227 * Rescan all packets and just run taps - don't reconstruct the display.
229 * @param cf the capture file
230 * @return one of cf_read_status_t
232 cf_read_status_t cf_retap_packets(capture_file *cf);
235 * The time format has changed, rescan all packets.
237 * @param cf the capture file
239 void cf_change_time_formats(capture_file *cf);
242 * Print the capture file.
244 * @param cf the capture file
245 * @param print_args the arguments what and how to print
246 * @return one of cf_print_status_t
248 cf_print_status_t cf_print_packets(capture_file *cf, print_args_t *print_args);
251 * Print (export) the capture file into PDML format.
253 * @param cf the capture file
254 * @param print_args the arguments what and how to export
255 * @return one of cf_print_status_t
257 cf_print_status_t cf_write_pdml_packets(capture_file *cf, print_args_t *print_args);
260 * Print (export) the capture file into PSML format.
262 * @param cf the capture file
263 * @param print_args the arguments what and how to export
264 * @return one of cf_print_status_t
266 cf_print_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args);
269 * Find Packet in protocol tree.
271 * @param cf the capture file
272 * @param string the string to find
273 * @return TRUE if a packet was found, FALSE otherwise
275 gboolean cf_find_packet_protocol_tree(capture_file *cf, const char *string);
278 * Find Packet in summary line.
280 * @param cf the capture file
281 * @param string the string to find
282 * @return TRUE if a packet was found, FALSE otherwise
284 gboolean cf_find_packet_summary_line(capture_file *cf, const char *string);
287 * Find Packet in packet data.
289 * @param cf the capture file
290 * @param string the string to find
291 * @param string_size the size of the string to find
292 * @return TRUE if a packet was found, FALSE otherwise
294 gboolean cf_find_packet_data(capture_file *cf, const guint8 *string,
298 * Find Packet by display filter.
300 * @param cf the capture file
301 * @param sfcode the display filter to find a packet for
302 * @return TRUE if a packet was found, FALSE otherwise
304 gboolean cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode);
307 * GoTo Packet in first row.
309 * @param cf the capture file
310 * @return TRUE if the first row exists, FALSE otherwise
312 gboolean cf_goto_top_frame(capture_file *cf);
315 * GoTo Packet in last row.
317 * @param cf the capture file
318 * @return TRUE if last row exists, FALSE otherwise
320 gboolean cf_goto_bottom_frame(capture_file *cf);
323 * GoTo Packet with the given row.
325 * @param cf the capture file
326 * @param row the row to go to
327 * @return TRUE if this row exists, FALSE otherwise
329 gboolean cf_goto_frame(capture_file *cf, guint row);
332 * Go to frame specified by currently selected protocol tree field.
333 * (Go To Corresponding Packet)
334 * @todo this is ugly and should be improved!
336 * @param cf the capture file
337 * @return TRUE if this packet exists, FALSE otherwise
339 gboolean cf_goto_framenum(capture_file *cf);
342 * Select the packet in the given row.
344 * @param cf the capture file
345 * @param row the row to select
347 void cf_select_packet(capture_file *cf, int row);
350 * Unselect all packets, if any.
352 * @param cf the capture file
353 * @param row the row to select
355 void cf_unselect_packet(capture_file *cf);
358 * Unselect all protocol tree fields, if any.
360 * @param cf the capture file
361 * @param row the row to select
363 void cf_unselect_field(capture_file *cf);
366 * Mark a particular frame in a particular capture.
368 * @param cf the capture file
369 * @param frame the frame to be marked
371 void cf_mark_frame(capture_file *cf, frame_data *frame);
374 * Unmark a particular frame in a particular capture.
376 * @param cf the capture file
377 * @param frame the frame to be unmarked
379 void cf_unmark_frame(capture_file *cf, frame_data *frame);
382 * Convert error number and info to a complete message.
384 * @param err the error number
385 * @param err_info the additional info about this error (e.g. filename)
386 * @return statically allocated error message
388 char *cf_read_error_message(int err, const gchar *err_info);
391 * Merge two (or more) capture files into one.
392 * @todo is this the right place for this function? It doesn't have to do a lot with capture_file.
394 * @param out_filename output filename
395 * @param out_fd output file descriptor
396 * @param in_file_count the number of input files to merge
397 * @param in_filnames array of input filenames
398 * @param file_type the output filetype
399 * @param do_append FALSE to merge chronologically, TRUE simply append
400 * @return TRUE if merging suceeded, FALSE otherwise
403 cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
404 char *const *in_filenames, int file_type, gboolean do_append);