return FALSE;
}
/* Capture succeeded; attempt to read in the capture file. */
- if ((err = cf_open(capture_opts->save_file, is_tempfile, capture_opts->cf)) != 0) {
+ if (cf_open(capture_opts->cf, capture_opts->save_file, is_tempfile, &err) != CF_OK) {
/* We're not doing a capture any more, so we don't have a save
file. */
if (capture_opts->multi_files_on) {
}
switch (cf_read(capture_opts->cf)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Exit by leaving the main loop, so that any quit functions
we registered get called. */
main_window_nested_quit();
/* The child process started a capture.
Attempt to open the capture file and set up to read it. */
- err = cf_start_tail(capture_opts->save_file, is_tempfile, capture_opts->cf);
- if (err != 0) {
- /* We weren't able to open the capture file; user has been
- alerted. Close the sync pipe. */
+ switch(cf_start_tail(capture_opts->cf, capture_opts->save_file, is_tempfile, &err)) {
+ case CF_OK:
+ /* We were able to open and set up to read the capture file;
+ arrange that our callback be called whenever it's possible
+ to read from the sync pipe, so that it's called when
+ the child process wants to tell us something. */
+ pipe_input_set_handler(sync_pipe[PIPE_READ], (gpointer) capture_opts, &capture_opts->fork_child, sync_pipe_input_cb);
+
+ return TRUE;
+ break;
+ case CF_ERROR:
+ /* We weren't able to open the capture file; user has been
+ alerted. Close the sync pipe. */
- close(sync_pipe[PIPE_READ]);
+ close(sync_pipe[PIPE_READ]);
- /* Don't unlink the save file - leave it around, for debugging
- purposes. */
- g_free(capture_opts->save_file);
- capture_opts->save_file = NULL;
- return FALSE;
+ /* Don't unlink the save file - leave it around, for debugging
+ purposes. */
+ g_free(capture_opts->save_file);
+ capture_opts->save_file = NULL;
+ return FALSE;
+ break;
+ default:
+ g_assert_not_reached();
+ return FALSE;
}
- /* We were able to open and set up to read the capture file;
- arrange that our callback be called whenever it's possible
- to read from the sync pipe, so that it's called when
- the child process wants to tell us something. */
- pipe_input_set_handler(sync_pipe[PIPE_READ], (gpointer) capture_opts, &capture_opts->fork_child, sync_pipe_input_cb);
-
- return TRUE;
}
XXX - do something if this fails? */
switch (cf_finish_tail(capture_opts->cf, &err)) {
- case READ_SUCCESS:
+ case CF_OK:
if(cf_packet_count(capture_opts->cf) == 0) {
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
"%sNo packets captured!%s\n\n"
cf_close(capture_opts->cf);
}
break;
- case READ_ERROR:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Exit by leaving the main loop, so that any quit functions
we registered get called. */
main_window_quit();
XXX - do something if this fails? */
switch (cf_continue_tail(capture_opts->cf, to_read, &err)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file.
XXX - abort on a read error? */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Kill the child capture process; the user wants to exit, and we
shouldn't just leave it running. */
kill_capture_child(capture_opts);
#include <epan/prefs.h>
#include <epan/dfilter/dfilter.h>
#include <epan/conversation.h>
-#include "globals.h"
#include <epan/epan_dissect.h>
#include <epan/tap.h>
#include "tap_dfilter_dlg.h"
#define FRAME_DATA_CHUNK_SIZE 1024
-int
-cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
+cf_status_t
+cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err)
{
wtap *wth;
- int err;
gchar *err_info;
int fd;
struct stat cf_stat;
- wth = wtap_open_offline(fname, &err, &err_info, TRUE);
+ wth = wtap_open_offline(fname, err, &err_info, TRUE);
if (wth == NULL)
goto fail;
/* Find the size of the file. */
fd = wtap_fd(wth);
if (fstat(fd, &cf_stat) < 0) {
- err = errno;
+ *err = errno;
wtap_close(wth);
goto fail;
}
G_ALLOC_AND_FREE);
g_assert(cf->plist_chunk);
- return (0);
+ return CF_OK;
fail:
- cf_open_failure_alert_box(fname, err, err_info, FALSE, 0);
- return (err);
+ cf_open_failure_alert_box(fname, *err, err_info, FALSE, 0);
+ return CF_ERROR;
}
/* Reset everything to a pristine state */
}
cf->plist = NULL;
cf->plist_end = NULL;
- unselect_packet(cf); /* nothing to select */
+ cf_unselect_packet(cf); /* nothing to select */
cf->first_displayed = NULL;
cf->last_displayed = NULL;
g_free(win_name);
}
-read_status_t
+cf_status_t
cf_read(capture_file *cf)
{
int err;
if (stop_flag) {
/* Well, the user decided to abort the read. Destroy the progress
- bar, close the capture file, and return READ_ABORTED so our caller
+ bar, close the capture file, and return CF_ABORTED so our caller
can do whatever is appropriate when that happens. */
destroy_progress_dlg(progbar);
cf->state = FILE_READ_ABORTED; /* so that we're allowed to close it */
packet_list_thaw(); /* undo our freeze */
cf_close(cf);
- return (READ_ABORTED);
+ return CF_ABORTED;
}
read_packet(cf, data_offset);
}
}
snprintf(err_str, sizeof err_str, errmsg);
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, err_str);
- return (READ_ERROR);
+ return CF_ERROR;
} else
- return (READ_SUCCESS);
+ return CF_OK;
}
#ifdef HAVE_LIBPCAP
-int
-cf_start_tail(char *fname, gboolean is_tempfile, capture_file *cf)
+
+cf_start_tail(capture_file *cf, char *fname, gboolean is_tempfile, int *err)
{
- int err;
gchar *capture_msg;
+ cf_status_t cf_status;
- err = cf_open(fname, is_tempfile, cf);
- if (err == 0) {
+ cf_status = cf_open(cf, fname, is_tempfile, err);
+ if (cf_status == CF_OK) {
/* Disable menu items that make no sense if you're currently running
a capture. */
set_menus_for_capture_in_progress(TRUE);
statusbar_push_file_msg(capture_msg);
g_free(capture_msg);
+
}
- return err;
+ return cf_status;
}
-read_status_t
+cf_status_t
cf_continue_tail(capture_file *cf, int to_read, int *err)
{
long data_offset = 0;
packet_list_moveto_end();
if (cf->state == FILE_READ_ABORTED) {
- /* Well, the user decided to exit Ethereal. Return READ_ABORTED
+ /* Well, the user decided to exit Ethereal. Return CF_ABORTED
so that our caller can kill off the capture child process;
this will cause an EOF on the pipe from the child, so
"cf_finish_tail()" will be called, and it will clean up
and exit. */
- return READ_ABORTED;
+ return CF_ABORTED;
} else if (*err != 0) {
/* We got an error reading the capture file.
XXX - pop up a dialog box? */
- return (READ_ERROR);
+ return CF_ERROR;
} else
- return (READ_SUCCESS);
+ return CF_OK;
}
-read_status_t
+cf_status_t
cf_finish_tail(capture_file *cf, int *err)
{
gchar *err_info;
/* Well, the user decided to abort the read. We're only called
when the child capture process closes the pipe to us (meaning
it's probably exited), so we can just close the capture
- file; we return READ_ABORTED so our caller can do whatever
+ file; we return CF_ABORTED so our caller can do whatever
is appropriate when that happens. */
cf_close(cf);
- return READ_ABORTED;
+ return CF_ABORTED;
}
packet_list_thaw();
if (*err != 0) {
/* We got an error reading the capture file.
XXX - pop up a dialog box? */
- return (READ_ERROR);
+ return CF_ERROR;
} else {
- return (READ_SUCCESS);
+ return CF_OK;
}
}
#endif /* HAVE_LIBPCAP */
XXX - we must do this before we add the row to the display,
as, if the display's GtkCList's selection mode is
GTK_SELECTION_BROWSE, when the first entry is added to it,
- "select_packet()" will be called, and it will fetch the row
+ "cf_select_packet()" will be called, and it will fetch the row
data for the 0th row, and will get a null pointer rather than
"fdata", as "gtk_clist_append()" won't yet have returned and
thus "gtk_clist_set_row_data()" won't yet have been called.
We thus need to leave behind bread crumbs so that
- "select_packet()" can find this frame. See the comment
- in "select_packet()". */
+ "cf_select_packet()" can find this frame. See the comment
+ in "cf_select_packet()". */
if (cf->first_displayed == NULL)
cf->first_displayed = fdata;
return (!got_read_error && !got_write_error);
}
-gboolean
-filter_packets(capture_file *cf, gchar *dftext, gboolean force)
+cf_status_t
+cf_filter_packets(capture_file *cf, gchar *dftext, gboolean force)
{
dfilter_t *dfcode;
char *filter_new = dftext ? dftext : "";
/* if new filter equals old one, do nothing unless told to do so */
if (!force && strcmp(filter_new, filter_old) == 0) {
- return TRUE;
+ return CF_OK;
}
if (dftext == NULL) {
g_free(safe_dfilter_error_msg);
g_free(safe_dftext);
g_free(dftext);
- return FALSE;
+ return CF_ERROR;
}
/* Was it empty? */
} else {
rescan_packets(cf, "Filtering", dftext, TRUE, FALSE);
}
- return TRUE;
+ return CF_OK;
}
void
-colorize_packets(capture_file *cf)
+cf_colorize_packets(capture_file *cf)
{
rescan_packets(cf, "Colorizing", "all packets", FALSE, FALSE);
}
void
-reftime_packets(capture_file *cf)
+cf_reftime_packets(capture_file *cf)
{
rescan_packets(cf, "Updating Reftime", "all packets", FALSE, FALSE);
}
void
-redissect_packets(capture_file *cf)
+cf_redissect_packets(capture_file *cf)
{
rescan_packets(cf, "Reprocessing", "all packets", TRUE, TRUE);
}
if (selected_row == -1) {
/* There are no frames displayed at all. */
- unselect_packet(cf);
+ cf_unselect_packet(cf);
} else {
/* Either the frame that was selected passed the filter, or we've
found the nearest displayed frame to that frame. Select it, make
return TRUE;
}
-int
-retap_packets(capture_file *cf)
+cf_status_t
+cf_retap_packets(capture_file *cf)
{
packet_range_t range;
case PSP_STOPPED:
/* Well, the user decided to abort the refiltering.
Return FALSE so our caller knows they did that. */
- return FALSE;
+ return CF_ERROR;
case PSP_FAILED:
/* Error while retapping. */
- return FALSE;
+ return CF_ERROR;
}
- return TRUE;
+ return CF_OK;
}
typedef struct {
return FALSE;
}
-pp_return_t
-print_packets(capture_file *cf, print_args_t *print_args)
+cf_status_t
+cf_print_packets(capture_file *cf, print_args_t *print_args)
{
int i;
print_callback_args_t callback_args;
if (!print_preamble(print_args->stream, cf->filename)) {
destroy_print_stream(print_args->stream);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
if (print_args->print_summary) {
have to write to a file and then hand that to the print
program to make it actually not print anything. */
destroy_print_stream(print_args->stream);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
if (!print_finale(print_args->stream)) {
destroy_print_stream(print_args->stream);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
if (!destroy_print_stream(print_args->stream))
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
- return PP_OK;
+ return CF_OK;
}
static gboolean
return !ferror(fh);
}
-pp_return_t
-write_pdml_packets(capture_file *cf, print_args_t *print_args)
+cf_status_t
+cf_write_pdml_packets(capture_file *cf, print_args_t *print_args)
{
FILE *fh;
psp_return_t ret;
fh = fopen(print_args->file, "w");
if (fh == NULL)
- return PP_OPEN_ERROR; /* attempt to open destination failed */
+ return CF_PRINT_OPEN_ERROR; /* attempt to open destination failed */
write_pdml_preamble(fh);
if (ferror(fh)) {
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
/* Iterate through the list of packets, printing the packets we were
case PSP_FAILED:
/* Error while printing. */
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
write_pdml_finale(fh);
if (ferror(fh)) {
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
/* XXX - check for an error */
fclose(fh);
- return PP_OK;
+ return CF_OK;
}
static gboolean
return !ferror(fh);
}
-pp_return_t
-write_psml_packets(capture_file *cf, print_args_t *print_args)
+cf_status_t
+cf_write_psml_packets(capture_file *cf, print_args_t *print_args)
{
FILE *fh;
psp_return_t ret;
fh = fopen(print_args->file, "w");
if (fh == NULL)
- return PP_OPEN_ERROR; /* attempt to open destination failed */
+ return CF_PRINT_OPEN_ERROR; /* attempt to open destination failed */
write_psml_preamble(fh);
if (ferror(fh)) {
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
/* Iterate through the list of packets, printing the packets we were
case PSP_FAILED:
/* Error while printing. */
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
write_psml_finale(fh);
if (ferror(fh)) {
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
/* XXX - check for an error */
fclose(fh);
- return PP_OK;
+ return CF_OK;
}
/* Scan through the packet list and change all columns that use the
"command-line-specified" time stamp format to use the current
value of that format. */
void
-change_time_formats(capture_file *cf)
+cf_change_time_formats(capture_file *cf)
{
frame_data *fdata;
progdlg_t *progbar = NULL;
} match_data;
gboolean
-find_packet_protocol_tree(capture_file *cf, const char *string)
+cf_find_packet_protocol_tree(capture_file *cf, const char *string)
{
match_data mdata;
}
gboolean
-find_packet_summary_line(capture_file *cf, const char *string)
+cf_find_packet_summary_line(capture_file *cf, const char *string)
{
match_data mdata;
} cbs_t; /* "Counted byte string" */
gboolean
-find_packet_data(capture_file *cf, const guint8 *string, size_t string_size)
+cf_find_packet_data(capture_file *cf, const guint8 *string, size_t string_size)
{
cbs_t info;
}
gboolean
-find_packet_dfilter(capture_file *cf, dfilter_t *sfcode)
+cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode)
{
return find_packet(cf, match_dfilter, sfcode);
}
}
gboolean
-goto_frame(capture_file *cf, guint fnumber)
+cf_goto_frame(capture_file *cf, guint fnumber)
{
frame_data *fdata;
int row;
}
gboolean
-goto_top_frame(capture_file *cf)
+cf_goto_top_frame(capture_file *cf)
{
frame_data *fdata;
int row;
}
gboolean
-goto_bottom_frame(capture_file *cf)
+cf_goto_bottom_frame(capture_file *cf)
{
frame_data *fdata;
int row;
/*
* Go to frame specified by currently selected protocol tree item.
*/
-void
-goto_framenum(capture_file *cf)
+gboolean
+cf_goto_framenum(capture_file *cf)
{
header_field_info *hfinfo;
guint32 framenum;
if (hfinfo->type == FT_FRAMENUM) {
framenum = fvalue_get_integer(&cf->finfo_selected->value);
if (framenum != 0)
- goto_frame(cf, framenum);
+ return cf_goto_frame(cf, framenum);
}
}
+
+ return FALSE;
}
/* Select the packet on a given row. */
void
-select_packet(capture_file *cf, int row)
+cf_select_packet(capture_file *cf, int row)
{
frame_data *fdata;
int err;
our version and the vanilla GTK+ version).
This means that a "select-row" signal is emitted; this causes
- "packet_list_select_cb()" to be called, which causes "select_packet()"
+ "packet_list_select_cb()" to be called, which causes "cf_select_packet()"
to be called.
- "select_packet()" fetches, above, the data associated with the
+ "cf_select_packet()" fetches, above, the data associated with the
row that was selected; however, as "gtk_clist_append()", which
called "real_insert_row()", hasn't yet returned, we haven't yet
associated any data with that row, so we get back a null pointer.
/* Unselect the selected packet, if any. */
void
-unselect_packet(capture_file *cf)
+cf_unselect_packet(capture_file *cf)
{
/* Destroy the epan_dissect_t for the unselected packet. */
if (cf->edt != NULL) {
set_menus_for_selected_packet(cf);
/* No protocol tree means no selected field. */
- unselect_field(cf);
+ cf_unselect_field(cf);
}
/* Unset the selected protocol tree field, if any. */
void
-unselect_field(capture_file *cf)
+cf_unselect_field(capture_file *cf)
{
statusbar_pop_field_msg();
cf->finfo_selected = NULL;
* Mark a particular frame.
*/
void
-mark_frame(capture_file *cf, frame_data *frame)
+cf_mark_frame(capture_file *cf, frame_data *frame)
{
if (! frame->flags.marked) {
frame->flags.marked = TRUE;
* Unmark a particular frame.
*/
void
-unmark_frame(capture_file *cf, frame_data *frame)
+cf_unmark_frame(capture_file *cf, frame_data *frame)
{
if (frame->flags.marked) {
frame->flags.marked = FALSE;
return TRUE;
}
-gboolean
-cf_save(char *fname, capture_file *cf, packet_range_t *range, guint save_format)
+cf_status_t
+cf_save(capture_file *cf, char *fname, packet_range_t *range, guint save_format)
{
gchar *from_filename;
const gchar *name_ptr;
time if the file is large. */
cf->user_saved = TRUE;
- if ((err = cf_open(fname, FALSE, cf)) == 0) {
+ if ((cf_open(cf, fname, FALSE, &err)) == CF_OK) {
/* XXX - report errors if this fails?
What should we return if it fails or is aborted? */
switch (cf_read(cf)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just return (without
changing any menu settings; "cf_close()" set them
set_menus_for_unsaved_capture_file(FALSE);
}
}
- return TRUE;
+ return CF_OK;
fail:
/* Pop the "Saving:" message off the status bar. */
statusbar_pop_file_msg();
- return FALSE;
+ return CF_ERROR;
}
static void
/* Reload the current capture file. */
void
-cf_reload() {
+cf_reload(capture_file *cf) {
gchar *filename;
gboolean is_tempfile;
+ int err;
/* If the file could be opened, "cf_open()" calls "cf_close()"
to get rid of state for the old capture file before filling in state
a temporary file, mark it as not being a temporary file, and then
reopen it as the type of file it was.
- Also, "cf_close()" will free "cfile.filename", so we must make
+ Also, "cf_close()" will free "cf->filename", so we must make
a copy of it first. */
- filename = g_strdup(cfile.filename);
- is_tempfile = cfile.is_tempfile;
- cfile.is_tempfile = FALSE;
- if (cf_open(filename, is_tempfile, &cfile) == 0) {
- switch (cf_read(&cfile)) {
-
- case READ_SUCCESS:
- case READ_ERROR:
+ filename = g_strdup(cf->filename);
+ is_tempfile = cf->is_tempfile;
+ cf->is_tempfile = FALSE;
+ if (cf_open(cf, filename, is_tempfile, &err) == CF_OK) {
+ switch (cf_read(cf)) {
+
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
return;
}
} else {
- /* The open failed, so "cfile.is_tempfile" wasn't set to "is_tempfile".
- Instead, the file was left open, so we should restore "cfile.is_tempfile"
+ /* The open failed, so "cf->is_tempfile" wasn't set to "is_tempfile".
+ Instead, the file was left open, so we should restore "cf->is_tempfile"
ourselves.
XXX - change the menu? Presumably "cf_open()" will do that;
make sure it does! */
- cfile.is_tempfile = is_tempfile;
+ cf->is_tempfile = is_tempfile;
}
/* "cf_open()" made a copy of the file name we handed it, so
we should free up our copy. */
#include "cfile.h"
-/* Return values from "cf_read()", "cf_continue_tail()", and
- "cf_finish_tail()". */
+/** Return values from various cf_xxx functions. */
typedef enum {
- READ_SUCCESS, /* read succeeded */
- READ_ERROR, /* read got an error */
- READ_ABORTED /* read aborted by user */
-} read_status_t;
-
-int cf_open(char *, gboolean, capture_file *);
-void cf_close(capture_file *);
-void cf_reload(void);
-read_status_t cf_read(capture_file *);
-int cf_start_tail(char *, gboolean, capture_file *);
-read_status_t cf_continue_tail(capture_file *, int, int *);
-read_status_t cf_finish_tail(capture_file *, int *);
-/* size_t read_frame_header(capture_file *); */
-gboolean cf_save(char *fname, capture_file * cf, packet_range_t *range, guint save_format);
-const gchar *cf_get_display_name(capture_file *);
+ CF_OK, /**< operation succeeded */
+ CF_ERROR, /**< operation got an error (function may provide err with details) */
+ CF_ABORTED, /**< operation aborted by user */
+ CF_PRINT_OPEN_ERROR, /**< print operation failed while opening printer */
+ CF_PRINT_WRITE_ERROR /**< print operation failed while writing to the printer */
+} cf_status_t;
+
+/**
+ * Open a capture file.
+ *
+ * @param cf the capture file to be opened
+ * @param fname the filename to be opened
+ * @param is_tempfile is this a temporary file?
+ * @return one of cf_status_t
+ */
+cf_status_t cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err);
+
+/**
+ * Close a capture file.
+ *
+ * @param cf the capture file to be closed
+ */
+void cf_close(capture_file *cf);
+
+/**
+ * Reload a capture file.
+ *
+ * @param cf the capture file to be reloaded
+ */
+void cf_reload(capture_file *cf);
+
+/**
+ * Read all packets of a capture file into the internal structures.
+ *
+ * @param cf the capture file to be read
+ * @return one of cf_status_t
+ */
+cf_status_t cf_read(capture_file *cf);
+
+/**
+ * Start reading from the end of a capture file.
+ * This is used in "Update list of packets in Real-Time".
+ *
+ * @param cf the capture file to be read from
+ * @param fname the filename to be read from
+ * @param is_tempfile is this a temporary file?
+ * @param err the error code, if an error had occured
+ * @return one of cf_status_t
+ */
+cf_status_t cf_start_tail(capture_file *cf, char *fname, gboolean is_tempfile, int *err);
+
+/**
+ * Read packets from the "end" of a capture file.
+ *
+ * @param cf the capture file to be read from
+ * @param to_read the number of packets to read
+ * @param err the error code, if an error had occured
+ * @return one of cf_status_t
+ */
+cf_status_t cf_continue_tail(capture_file *cf, int to_read, int *err);
+
+/**
+ * Finish reading from "end" of a capture file.
+ *
+ * @param cf the capture file to be read from
+ * @param err the error code, if an error had occured
+ * @return one of cf_status_t
+ */
+cf_status_t cf_finish_tail(capture_file *cf, int *err);
+
+/**
+ * Save a capture file (or a range of it).
+ *
+ * @param cf the capture file to save to
+ * @param fname the filename to save to
+ * @param range the range of packets to save
+ * @param save_format the format of the file to save (libpcap, ...)
+ * @return one of cf_status_t
+ */
+cf_status_t cf_save(capture_file * cf, char *fname, packet_range_t *range, guint save_format);
+
+/**
+ * Get a displayable name of the capture file.
+ *
+ * @param cf the capture file
+ * @return the displayable name (don't have to be g_free'd)
+ */
+const gchar *cf_get_display_name(capture_file *cf);
+
+/**
+ * Get the number of packets in the capture file.
+ *
+ * @param cf the capture file
+ * @return the number of packets in the capture file
+ */
int cf_packet_count(capture_file *cf);
+
+/**
+ * Is this capture file a temporary file?
+ *
+ * @param cf the capture file
+ * @return TRUE if it's a temporary file, FALSE otherwise
+ */
gboolean cf_is_tempfile(capture_file *cf);
+
+/**
+ * Get the interface name to capture from.
+ *
+ * @param cf the capture file
+ * @return the interface name (don't have to be g_free'd)
+ */
+gchar *cf_get_iface(capture_file *cf);
+
+/**
+ * Get the capture filter of this capture file.
+ *
+ * @param cf the capture file
+ * @return the capture filter (don't have to be g_free'd)
+ */
+gchar *cf_get_cfilter(capture_file *cf);
+
+/**
+ * Set flag, if the number of packet drops while capturing are known or not.
+ *
+ * @param cf the capture file
+ * @param drops_known TRUE if the number of packet drops are known, FALSE otherwise
+ */
void cf_set_drops_known(capture_file *cf, gboolean drops_known);
+
+/**
+ * Set the number of packet drops while capturing.
+ *
+ * @param cf the capture file
+ * @param drops the number of packet drops occured while capturing
+ */
void cf_set_drops(capture_file *cf, guint32 drops);
-gchar *cf_get_iface(capture_file *cf);
+
+/**
+ * Set the read filter.
+ * @todo this shouldn't be required, remove it somehow
+ *
+ * @param cf the capture file
+ * @param rfcode the readfilter
+ */
void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode);
-gchar *cf_get_cfilter(capture_file *cf);
-gboolean
-cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
- char *const *in_filenames, int file_type, gboolean do_append);
+/**
+ * "Display Filter" packets in the capture file.
+ *
+ * @param cf the capture file
+ * @param dfilter the display filter
+ * @param force TRUE if do in any case, FALSE only if dfilter changed
+ * @return one of cf_status_t
+ */
+cf_status_t cf_filter_packets(capture_file *cf, gchar *dfilter, gboolean force);
-gboolean filter_packets(capture_file *cf, gchar *dfilter, gboolean force);
-void reftime_packets(capture_file *);
-void colorize_packets(capture_file *);
-void redissect_packets(capture_file *cf);
-int retap_packets(capture_file *cf);
-typedef enum {
- PP_OK,
- PP_OPEN_ERROR,
- PP_WRITE_ERROR
-} pp_return_t;
-pp_return_t print_packets(capture_file *cf, print_args_t *print_args);
-pp_return_t write_pdml_packets(capture_file *cf, print_args_t *print_args);
-pp_return_t write_psml_packets(capture_file *cf, print_args_t *print_args);
-
-void change_time_formats(capture_file *);
-
-gboolean find_packet_protocol_tree(capture_file *cf, const char *string);
-gboolean find_packet_summary_line(capture_file *cf, const char *string);
-gboolean find_packet_data(capture_file *cf, const guint8 *string,
+/**
+ * At least one "Refence Time" flag has changed, rescan all packets.
+ *
+ * @param cf the capture file
+ */
+void cf_reftime_packets(capture_file *cf);
+
+/**
+ * At least one "Refence Time" flag has changed, rescan all packets.
+ *
+ * @param cf the capture file
+ */
+void cf_colorize_packets(capture_file *cf);
+
+/**
+ * "Something" has changed, rescan all packets.
+ *
+ * @param cf the capture file
+ */
+void cf_redissect_packets(capture_file *cf);
+
+/**
+ * A tap listener want's to rescan all packets.
+ *
+ * @param cf the capture file
+ * @return one of cf_status_t
+ */
+cf_status_t cf_retap_packets(capture_file *cf);
+
+/**
+ * The time format has changed, rescan all packets.
+ *
+ * @param cf the capture file
+ */
+void cf_change_time_formats(capture_file *cf);
+
+/**
+ * Print the capture file.
+ *
+ * @param cf the capture file
+ * @param print_args the arguments what and how to print
+ * @return one of cf_status_t
+ */
+cf_status_t cf_print_packets(capture_file *cf, print_args_t *print_args);
+
+/**
+ * Print (export) the capture file into PDML format.
+ *
+ * @param cf the capture file
+ * @param print_args the arguments what and how to export
+ * @return one of cf_status_t
+ */
+cf_status_t cf_write_pdml_packets(capture_file *cf, print_args_t *print_args);
+
+/**
+ * Print (export) the capture file into PSML format.
+ *
+ * @param cf the capture file
+ * @param print_args the arguments what and how to export
+ * @return one of cf_status_t
+ */
+cf_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args);
+
+/**
+ * Find Packet in protocol tree.
+ *
+ * @param cf the capture file
+ * @param string the string to find
+ * @return TRUE if a packet was found, FALSE otherwise
+ */
+gboolean cf_find_packet_protocol_tree(capture_file *cf, const char *string);
+
+/**
+ * Find Packet in summary line.
+ *
+ * @param cf the capture file
+ * @param string the string to find
+ * @return TRUE if a packet was found, FALSE otherwise
+ */
+gboolean cf_find_packet_summary_line(capture_file *cf, const char *string);
+
+/**
+ * Find Packet in packet data.
+ *
+ * @param cf the capture file
+ * @param string the string to find
+ * @param string_size the size of the string to find
+ * @return TRUE if a packet was found, FALSE otherwise
+ */
+gboolean cf_find_packet_data(capture_file *cf, const guint8 *string,
size_t string_size);
-gboolean find_packet_dfilter(capture_file *cf, dfilter_t *sfcode);
-guint8 get_int_value(char char_val);
-gboolean find_ascii(capture_file *cf, char *ascii_text, gboolean ascii_search, char *ftype, gboolean case_type);
-gboolean find_in_gtk_data(capture_file *cf, gpointer *data, char *ascii_text, gboolean case_type, gboolean search_type);
-gboolean goto_frame(capture_file *cf, guint fnumber);
-gboolean goto_bottom_frame(capture_file *cf);
-gboolean goto_top_frame(capture_file *cf);
-void goto_framenum(capture_file *cf);
+/**
+ * Find Packet by display filter.
+ *
+ * @param cf the capture file
+ * @param sfcode the display filter to find a packet for
+ * @return TRUE if a packet was found, FALSE otherwise
+ */
+gboolean cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode);
+/**
+ * GoTo Packet in first row.
+ *
+ * @param cf the capture file
+ * @return TRUE if the first row exists, FALSE otherwise
+ */
+gboolean cf_goto_top_frame(capture_file *cf);
-void select_packet(capture_file *, int);
-void unselect_packet(capture_file *);
+/**
+ * GoTo Packet in last row.
+ *
+ * @param cf the capture file
+ * @return TRUE if last row exists, FALSE otherwise
+ */
+gboolean cf_goto_bottom_frame(capture_file *cf);
-void unselect_field(capture_file *);
+/**
+ * GoTo Packet with the given row.
+ *
+ * @param cf the capture file
+ * @param row the row to go to
+ * @return TRUE if this row exists, FALSE otherwise
+ */
+gboolean cf_goto_frame(capture_file *cf, guint row);
+
+/**
+ * Go to frame specified by currently selected protocol tree field.
+ * (Go To Corresponding Packet)
+ * @todo this is ugly and should be improved!
+ *
+ * @param cf the capture file
+ * @return TRUE if this packet exists, FALSE otherwise
+ */
+gboolean cf_goto_framenum(capture_file *cf);
+
+/**
+ * Select the packet in the given row.
+ *
+ * @param cf the capture file
+ * @param row the row to select
+ */
+void cf_select_packet(capture_file *cf, int row);
+
+/**
+ * Unselect all packets, if any.
+ *
+ * @param cf the capture file
+ * @param row the row to select
+ */
+void cf_unselect_packet(capture_file *cf);
+
+/**
+ * Unselect all protocol tree fields, if any.
+ *
+ * @param cf the capture file
+ * @param row the row to select
+ */
+void cf_unselect_field(capture_file *cf);
-/*
+/**
* Mark a particular frame in a particular capture.
+ *
+ * @param cf the capture file
+ * @param frame the frame to be marked
*/
-void mark_frame(capture_file *, frame_data *);
+void cf_mark_frame(capture_file *cf, frame_data *frame);
-/*
+/**
* Unmark a particular frame in a particular capture.
+ *
+ * @param cf the capture file
+ * @param frame the frame to be unmarked
*/
-void unmark_frame(capture_file *, frame_data *);
+void cf_unmark_frame(capture_file *cf, frame_data *frame);
-/* Moves or copies a file. Returns 0 on failure, 1 on success */
-int file_mv(char *from, char *to);
+/**
+ * Convert error number and info to a complete message.
+ *
+ * @param err the error number
+ * @param err_info the additional info about this error (e.g. filename)
+ * @return statically allocated error message
+ */
+char *cf_read_error_message(int err, gchar *err_info);
-/* Copies a file. Returns 0 on failure, 1 on success */
-int file_cp(char *from, char *to);
+/**
+ * Merge two (or more) capture files into one.
+ * @todo is this the right place for this function? It doesn't have to do a lot with capture_file.
+ *
+ * @param out_filename output filename
+ * @param out_fd output file descriptor
+ * @param in_file_count the number of input files to merge
+ * @param in_filnames array of input filenames
+ * @param file_type the output filetype
+ * @param do_append FALSE to merge chronologically, TRUE simply append
+ * @return TRUE if merging suceeded, FALSE otherwise
+ */
+gboolean
+cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
+ char *const *in_filenames, int file_type, gboolean do_append);
-char *cf_read_error_message(int, gchar *);
#endif /* file.h */
window_present(sp->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg dhcp_stat_dlg = {
"Could not delete filter file: %s", strerror(errno));
/* colorize list */
- colorize_packets(&cfile);
+ cf_colorize_packets(&cfile);
/* Destroy the dialog box. */
/* XXX: is this useful? user might want to continue with editing new colors */
color_ok_cb(GtkButton *button _U_, gpointer user_data _U_)
{
/* colorize list */
- colorize_packets(&cfile);
+ cf_colorize_packets(&cfile);
/* Destroy the dialog box. */
window_destroy(colorize_win);
static void
color_apply_cb(GtkButton *button _U_, gpointer user_data _U_)
{
- colorize_packets(&cfile);
+ cf_colorize_packets(&cfile);
}
/* Create an "Edit Color Filter" dialog for a given color filter, and
gtk_widget_show_all(conversations->win);
window_present(conversations->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* Keep clist frozen to cause modifications to the clist (inserts, appends, others that are extremely slow
gtk_widget_show_all(win);
window_present(win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* after retapping, redraw table */
for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) {
gtk_widget_show_all(rs->win);
window_present(rs->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
decode_dcerpc_reset_all();
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
g_slist_free(decode_dimmable);
decode_dimmable = NULL;
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
/*
func = OBJECT_GET_DATA(notebook_pg, E_PAGE_ACTION);
func(notebook_pg);
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
/*
gtk_widget_show_all(fc->win);
window_present(fc->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
}
/* Try to open the capture file. */
- if ((err = cf_open(cf_name, FALSE, &cfile)) != 0) {
+ if (cf_open(&cfile, cf_name, FALSE, &err) != CF_OK) {
/* We couldn't open it; don't dismiss the open dialog box,
just leave it around so that the user can, after they
dismiss the alert box popped up for the open error,
switch (cf_read(&cfile)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
window_destroy(GTK_WIDGET (fs));
/* Try to open the merged capture file. */
- if ((err = cf_open(tmpname, TRUE /* temporary file */, &cfile)) != 0) {
+ if (cf_open(&cfile, tmpname, TRUE /* temporary file */, &err) != CF_OK) {
/* We couldn't open it; don't dismiss the open dialog box,
just leave it around so that the user can, after they
dismiss the alert box popped up for the open error,
switch (cf_read(&cfile)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
/* Write out the packets (all, or only the ones from the current
range) to the file with the specified name. */
- if (! cf_save(cf_name, &cfile, &range, filetype)) {
+ if (cf_save(&cfile, cf_name, &range, filetype) != CF_OK) {
/* The write failed; don't dismiss the open dialog box,
just leave it around so that the user can, after they
dismiss the alert box popped up for the error, try again. */
}
/* The write succeeded; get rid of the file selection box. */
- /* cf_save might already closed our dialog! */
+ /* cf_save() might already closed our dialog! */
if (file_save_as_w)
window_destroy(GTK_WIDGET (fs));
/* Reload a file using the current read and display filters */
void
file_reload_cmd_cb(GtkWidget *w _U_, gpointer data _U_) {
- cf_reload();
+ cf_reload(&cfile);
}
/******************** Color Filters *********************************/
cfile.summary_data = summary_data;
if (cfile.hex) {
- found_packet = find_packet_data(&cfile, bytes, nbytes);
+ found_packet = cf_find_packet_data(&cfile, bytes, nbytes);
g_free(bytes);
if (!found_packet) {
/* We didn't find a packet */
/* OK, what are we searching? */
if (cfile.decode_data) {
/* The text in the protocol tree */
- found_packet = find_packet_protocol_tree(&cfile, string);
+ found_packet = cf_find_packet_protocol_tree(&cfile, string);
g_free(string);
if (!found_packet) {
/* We didn't find the packet. */
}
} else if (cfile.summary_data) {
/* The text in the summary line */
- found_packet = find_packet_summary_line(&cfile, string);
+ found_packet = cf_find_packet_summary_line(&cfile, string);
g_free(string);
if (!found_packet) {
/* We didn't find the packet. */
}
} else {
/* The raw packet data */
- found_packet = find_packet_data(&cfile, string, strlen(string));
+ found_packet = cf_find_packet_data(&cfile, string, strlen(string));
g_free(string);
if (!found_packet) {
/* We didn't find the packet. */
}
}
} else {
- found_packet = find_packet_dfilter(&cfile, sfcode);
+ found_packet = cf_find_packet_dfilter(&cfile, sfcode);
dfilter_free(sfcode);
if (!found_packet) {
/* We didn't find a packet */
*/
return;
}
- find_packet_data(&cfile, bytes, nbytes);
+ cf_find_packet_data(&cfile, bytes, nbytes);
g_free(bytes);
} else if (cfile.string) {
string = convert_string_case(cfile.sfilter, cfile.case_type);
/* OK, what are we searching? */
if (cfile.decode_data) {
/* The text in the protocol tree */
- find_packet_protocol_tree(&cfile, string);
+ cf_find_packet_protocol_tree(&cfile, string);
} else if (cfile.summary_data) {
/* The text in the summary line */
- find_packet_summary_line(&cfile, string);
+ cf_find_packet_summary_line(&cfile, string);
} else {
/* The raw packet data */
- find_packet_data(&cfile, string, strlen(string));
+ cf_find_packet_data(&cfile, string, strlen(string));
}
g_free(string);
} else {
*/
return;
}
- find_packet_dfilter(&cfile, sfcode);
+ cf_find_packet_dfilter(&cfile, sfcode);
dfilter_free(sfcode);
}
} else
*/
return;
}
- find_packet_dfilter(&cfile, sfcode);
+ cf_find_packet_dfilter(&cfile, sfcode);
dfilter_free(sfcode);
cfile.sbackward=sbackwards_saved;
}
return;
}
- if (goto_frame(&cfile, fnumber)) {
+ if (cf_goto_frame(&cfile, fnumber)) {
/* We succeeded in going to that frame; we're done. */
window_destroy(GTK_WIDGET(parent_w));
}
void
goto_framenum_cb(GtkWidget *w _U_, gpointer data _U_)
{
- goto_framenum(&cfile);
+ cf_goto_framenum(&cfile);
}
void
goto_top_frame_cb(GtkWidget *w _U_, gpointer d _U_)
{
- goto_top_frame(&cfile);
+ cf_goto_top_frame(&cfile);
}
void
goto_bottom_frame_cb(GtkWidget *w _U_, gpointer d _U_)
{
- goto_bottom_frame(&cfile);
+ cf_goto_bottom_frame(&cfile);
}
user_data->dlg.needs_redraw=TRUE;
dialog_graph_draw(user_data);
- goto_frame(&cfile, user_data->dlg.items[item].frame_num);
+ cf_goto_frame(&cfile, user_data->dlg.items[item].frame_num);
return TRUE;
}
gtk_widget_show_all(hs->win);
window_present(hs->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
void
gtk_widget_show_all(hs->win);
window_present(hs->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
void
if (user_data->selected_clist1!=NULL) {
fnumber = GPOINTER_TO_UINT(gtk_clist_get_row_data(
GTK_CLIST(user_data->selected_clist1), user_data->selected_row) );
- goto_frame(&cfile, fnumber);
+ cf_goto_frame(&cfile, fnumber);
}
}
}
/* retap all packets */
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* remove tap listener again */
protect_thread_critical_region();
h245conversations_init_tap();
/* Scan for H323 conversations conversationss (redissect all packets) */
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* Show the dialog box with the list of conversationss */
h323conversations_dlg_show(h323conversations_get_info()->strinfo_list);
gtk_widget_show_all(hosttable->win);
window_present(hosttable->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* Keep clist frozen to cause modifications to the clist (inserts, appends, others that are extremely slow
in GTK2) to not be drawn, allow refreshes to occur at strategic points for performance */
gtk_widget_show_all(win);
window_present(win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* after retapping, redraw table */
for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) {
window_present(sp->win);
http_init_hash(sp);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg http_stat_dlg = {
/* build the GUI */
init_io_stat_window(io);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
io_stat_redraw(io);
}
val=(int)OBJECT_GET_DATA(item, "tick_interval");
io->interval=val;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
io_stat_redraw(io);
}
io_stat_reset(gio->io);
enable_graph(gio, filter, field);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
io_stat_redraw(gio->io);
return 0;
gtk_widget_show_all(ldap->win);
window_present(ldap->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
}
-/* call filter_packets() and add this filter string to the recent filter list */
+/* call cf_filter_packets() and add this filter string to the recent filter list */
gboolean
main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force)
{
gboolean add_filter = TRUE;
gboolean free_filter = TRUE;
char *s;
- gboolean filter_packets_ret;
-
+ cf_status_t cf_status;
s = g_strdup(dftext);
/* GtkCombos don't let us get at their list contents easily, so we maintain
our own filter list, and feed it to gtk_combo_set_popdown_strings when
a new filter is added. */
- if ((filter_packets_ret = filter_packets(cf, s, force))) {
+ cf_status = cf_filter_packets(cf, s, force);
+ if (cf_status == CF_OK) {
li = g_list_first(filter_list);
while (li) {
if (li->data && strcmp(s, li->data) == 0)
if (free_filter)
g_free(s);
- return filter_packets_ret;
+ if (cf_status == CF_OK) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
} else {
frame->flags.ref_time=0;
}
- reftime_packets(&cfile);
+ cf_reftime_packets(&cfile);
}
void
if (byte_data == NULL)
return; /* none */
- unselect_field(&cfile);
+ cf_unselect_field(&cfile);
packet_hex_print(GTK_TEXT_VIEW(byte_view), byte_data,
cfile.current_frame, NULL, byte_len);
return;
if (data == NULL)
return; /* none */
- unselect_field(&cfile);
+ cf_unselect_field(&cfile);
packet_hex_print(GTK_TEXT(byte_view), data, cfile.current_frame,
NULL, len);
}
cf_close(&cfile);
/* Try to open the merged capture file. */
- if ((err = cf_open(tmpname, TRUE /* temporary file */, &cfile)) != 0) {
+ if (cf_open(&cfile, tmpname, TRUE /* temporary file */, &err) != CF_OK) {
/* We couldn't open it; don't dismiss the open dialog box,
just leave it around so that the user can, after they
dismiss the alert box popped up for the open error,
switch (cf_read(&cfile)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
break;
case(1):
/* open and read the capture file (this will close an existing file) */
- if ((err = cf_open(in_filenames[0], FALSE, &cfile)) == 0) {
+ if (cf_open(&cfile, in_filenames[0], FALSE, &err) == CF_OK) {
cf_read(&cfile);
add_menu_recent_capture_file(in_filenames[0]);
} else {
}
}
if (!rfilter_parse_failed) {
- if ((err = cf_open(cf_name, FALSE, &cfile)) == 0) {
+ if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
/* "cf_open()" succeeded, so it closed the previous
capture file, and thus destroyed any previous read filter
attached to "cf". */
/* Read the capture file. */
switch (cf_read(&cfile)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Exit now. */
gtk_exit(0);
break;
extern void main_widgets_show_or_hide(void);
/** Apply a new filter string.
- * Call filter_packets() and add this filter string to the recent filter list.
+ * Call cf_filter_packets() and add this filter string to the recent filter list.
*
* @param cf the capture file
* @param dftext the new filter string
gtk_label_get(GTK_LABEL(menu_item_child), &cf_name);
/* open and read the capture file (this will close an existing file) */
- if ((err = cf_open(cf_name, FALSE, &cfile)) == 0) {
+ if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
cf_read(&cfile);
} else {
/* the capture file isn't existing any longer, remove menu item */
if (recent.gui_time_format != TS_ABSOLUTE) {
set_timestamp_setting(TS_ABSOLUTE);
recent.gui_time_format = TS_ABSOLUTE;
- change_time_formats(&cfile);
+ cf_change_time_formats(&cfile);
}
}
if (recent.gui_time_format != TS_ABSOLUTE_WITH_DATE) {
set_timestamp_setting(TS_ABSOLUTE_WITH_DATE);
recent.gui_time_format = TS_ABSOLUTE_WITH_DATE;
- change_time_formats(&cfile);
+ cf_change_time_formats(&cfile);
}
}
if (recent.gui_time_format != TS_RELATIVE) {
set_timestamp_setting(TS_RELATIVE);
recent.gui_time_format = TS_RELATIVE;
- change_time_formats(&cfile);
+ cf_change_time_formats(&cfile);
}
}
if (recent.gui_time_format != TS_DELTA) {
set_timestamp_setting(TS_DELTA);
recent.gui_time_format = TS_DELTA;
- change_time_formats(&cfile);
+ cf_change_time_formats(&cfile);
}
}
gtk_widget_show_all(ms->win);
window_present(ms->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg mgcp_srt_dlg = {
/* goto that packet but don't change history */
ignore_jump = TRUE;
- goto_frame(&cfile, GPOINTER_TO_INT(previous->data) +1);
+ cf_goto_frame(&cfile, GPOINTER_TO_INT(previous->data) +1);
ignore_jump = FALSE;
}
}
/* goto that packet but don't change history */
ignore_jump = TRUE;
- goto_frame(&cfile, GPOINTER_TO_INT(next->data) +1);
+ cf_goto_frame(&cfile, GPOINTER_TO_INT(next->data) +1);
ignore_jump = FALSE;
}
}
while( (gtk_notebook_get_nth_page( GTK_NOTEBOOK(byte_nb_ptr), 0)))
gtk_notebook_remove_page( GTK_NOTEBOOK(byte_nb_ptr), 0);
- select_packet(&cfile, row);
+ cf_select_packet(&cfile, row);
gtk_widget_grab_focus(packet_list);
packet_history_add(row);
}
static void
packet_list_unselect_cb(GtkWidget *w _U_, gint row _U_, gint col _U_, gpointer evt _U_) {
- unselect_packet(&cfile);
+ cf_unselect_packet(&cfile);
}
/* mark packets */
if (row == -1)
return;
if (set) {
- mark_frame(&cfile, frame);
+ cf_mark_frame(&cfile, frame);
color_t_to_gdkcolor(&fg, &prefs.gui_marked_fg);
color_t_to_gdkcolor(&bg, &prefs.gui_marked_bg);
eth_clist_set_foreground(ETH_CLIST(packet_list), row, &fg);
} else {
color_filter_t *cfilter = frame->color_filter;
- unmark_frame(&cfile, frame);
+ cf_unmark_frame(&cfile, frame);
/* Restore the color from the matching color filter if any */
if (cfilter) { /* The packet matches a color filter */
color_t_to_gdkcolor(&fg, &cfilter->fg_color);
}
if (cfile.finfo_selected)
- unselect_packet(&cfile);
+ cf_unselect_packet(&cfile);
mode = new_mode;
eth_clist_set_selection_mode(ETH_CLIST(packet_list), mode);
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
#ifdef _WIN32
gboolean win_printer = FALSE;
#endif
- pp_return_t status;
+ cf_status_t status;
args = (print_args_t *)OBJECT_GET_DATA(ok_bt, PRINT_ARGS_KEY);
/* Now print/export the packets */
if (export_as_pdml)
- status = write_pdml_packets(&cfile, args);
+ status = cf_write_pdml_packets(&cfile, args);
else if (export_as_psml)
- status = write_psml_packets(&cfile, args);
+ status = cf_write_psml_packets(&cfile, args);
else {
switch (args->format) {
g_assert_not_reached();
return;
}
- status = print_packets(&cfile, args);
+ status = cf_print_packets(&cfile, args);
}
switch (status) {
- case PP_OK:
+ case CF_OK:
break;
- case PP_OPEN_ERROR:
+ case CF_PRINT_OPEN_ERROR:
if (args->to_file)
open_failure_alert_box(args->file, errno, TRUE);
else
args->cmd);
break;
- case PP_WRITE_ERROR:
+ case CF_PRINT_WRITE_ERROR:
if (args->to_file)
write_failure_alert_box(args->file, errno);
else
redissect = set_proto_selection(GTK_WIDGET(parent_w));
window_destroy(GTK_WIDGET(parent_w));
if (redissect)
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
static void
proto_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
{
if (set_proto_selection(GTK_WIDGET(parent_w)))
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
static void
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
redissect = revert_proto_selection();
window_destroy(GTK_WIDGET(parent_w));
if (redissect)
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
static gboolean
The only workaround is to freshly select the frame, which will remove any
existing notebook tabs and "restart" the whole byte view again. */
if (cfile.current_frame != NULL)
- goto_frame(&cfile, cfile.current_frame->num);
+ cf_goto_frame(&cfile, cfile.current_frame->num);
#endif
}
tree_view_follow_link(field_info *fi)
{
if(fi->hfinfo->type == FT_FRAMENUM) {
- goto_frame(&cfile, fi->value.value.integer);
+ cf_goto_frame(&cfile, fi->value.value.integer);
}
}
gtk_widget_show_all(win);
window_present(win);
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
static void
gtk_widget_show_all(rs->win);
window_present(rs->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
}
enable_graph(dgg);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
dialog_graph_redraw(dgg->ud);
return 0;
val=(int)OBJECT_GET_DATA(item, "tick_interval");
user_data->dlg.dialog_graph.interval=val;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
dialog_graph_redraw(user_data);
}
if (user_data->dlg.selected_clist!=NULL) {
fnumber = GPOINTER_TO_UINT(gtk_clist_get_row_data(
GTK_CLIST(user_data->dlg.selected_clist), user_data->dlg.selected_row) );
- goto_frame(&cfile, fnumber);
+ cf_goto_frame(&cfile, fnumber);
}
}
}
/* retap all packets */
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* draw statistics info */
draw_stat(user_data);
if (rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_fwd)==0
|| rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_rev)==0)
{
- mark_frame(&cfile, pinfo->fd);
+ cf_mark_frame(&cfile, pinfo->fd);
}
}
register_tap_listener_rtp_stream();
the_tapinfo_struct.mode = TAP_ANALYSE;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
if (!was_registered)
remove_tap_listener_rtp_stream();
the_tapinfo_struct.mode = TAP_SAVE;
the_tapinfo_struct.filter_stream_fwd = stream;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
the_tapinfo_struct.mode = TAP_ANALYSE;
if (!was_registered)
the_tapinfo_struct.mode = TAP_MARK;
the_tapinfo_struct.filter_stream_fwd = stream_fwd;
the_tapinfo_struct.filter_stream_rev = stream_rev;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
the_tapinfo_struct.mode = TAP_ANALYSE;
if (!was_registered)
{
if (selected_stream_fwd)
{
- goto_frame(&cfile, selected_stream_fwd->first_frame_num);
+ cf_goto_frame(&cfile, selected_stream_fwd->first_frame_num);
}
}
*/
return;
if (selected_packet)
- goto_frame(&cfile, selected_packet->frame_number);
+ cf_goto_frame(&cfile, selected_packet->frame_number);
}
SIGNAL_CONNECT(bt_close, "clicked", sctp_stat_on_close, NULL);
sctp_stat_dlg = sctp_stat_dlg_w;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
window_present(sp->win);
sip_init_hash(sp);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg sip_stat_dlg = {
gtk_widget_show_all(ss->win);
window_present(ss->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
break;
case ELMT_LINE:
if (line_detect_collision (e, x, y))
- goto_frame(&cfile, e->parent->num);
+ cf_goto_frame(&cfile, e->parent->num);
break;
case ELMT_ARC:
if (arc_detect_collision (e, x, y))
- goto_frame(&cfile, e->parent->num);
+ cf_goto_frame(&cfile, e->parent->num);
break;
default:
break;
}
/* Scan for VoIP calls calls (redissect all packets) */
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* Tap listener will be removed and cleaned up in voip_calls_on_destroy */
}
gtk_widget_show_all(sp->win);
window_present(sp->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg wsp_stat_dlg = {
setgid(getgid());
#endif
- err = cf_open(cf_name, FALSE, &cfile);
- if (err != 0) {
+ if (cf_open(&cfile, cf_name, FALSE, &err) != CF_OK) {
epan_cleanup();
exit(2);
}
fprintf(stderr, "\n");
}
-int
-cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
+cf_status_t
+cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err)
{
wtap *wth;
- int err;
gchar *err_info;
char err_msg[2048+1];
- wth = wtap_open_offline(fname, &err, &err_info, FALSE);
+ wth = wtap_open_offline(fname, err, &err_info, FALSE);
if (wth == NULL)
goto fail;
firstsec = 0, firstusec = 0;
prevsec = 0, prevusec = 0;
- return (0);
+ return CF_OK;
fail:
snprintf(err_msg, sizeof err_msg,
- cf_open_error_message(err, err_info, FALSE, 0), fname);
+ cf_open_error_message(*err, err_info, FALSE, 0), fname);
fprintf(stderr, "tethereal: %s\n", err_msg);
- return (err);
+ return CF_ERROR;
}
#ifdef HAVE_LIBPCAP