From 65ee4e797adad6f26d5672bc0b4fbd00d7e41301 Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Wed, 26 May 2010 19:11:23 +0000 Subject: [PATCH] From Jakub Zawadzki: New functions: cf_read_frame_r, cf_read_frame It's much easier to write: cf_read_frame (cf, fdata, &err, &err_info) Than: wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header, cf->pd, fdata->cap_len, &err, &err_info) svn path=/trunk/; revision=32980 --- file.c | 30 ++++++++++++++++++++---------- file.h | 7 +++++++ gtk/iax2_analysis.c | 3 +-- gtk/main.c | 3 +-- gtk/packet_list_store.c | 3 +-- gtk/packet_win.c | 3 +-- gtk/rtp_analysis.c | 3 +-- gtk/sctp_assoc_analyse.c | 3 +-- gtk/tcp_graph.c | 3 +-- proto_hier_stats.c | 3 +-- 10 files changed, 35 insertions(+), 26 deletions(-) diff --git a/file.c b/file.c index 2c6c3eb546..eb31d54588 100644 --- a/file.c +++ b/file.c @@ -1712,6 +1712,21 @@ cf_redissect_packets(capture_file *cf) rescan_packets(cf, "Reprocessing", "all packets", TRUE, TRUE); } +gboolean +cf_read_frame_r(capture_file *cf, frame_data *fdata, + union wtap_pseudo_header *pseudo_header, guint8 *pd, + int *err, gchar **err_info) +{ + return wtap_seek_read(cf->wth, fdata->file_off, pseudo_header, + pd, fdata->cap_len, err, err_info); +} + +gboolean +cf_read_frame(capture_file *cf, frame_data *fdata, int *err, gchar **err_info) +{ + return cf_read_frame_r(cf, fdata, &cf->pseudo_header, cf->pd, err, err_info); +} + /* Rescan the list of packets, reconstructing the CList. "action" describes why we're doing this; it's used in the progress @@ -1907,8 +1922,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, fdata->col_text = se_alloc0(sizeof(fdata->col_text) * (cf->cinfo.num_cols)); } - if (!wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header, - cf->pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame (cf, fdata, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cf->filename); break; @@ -2211,8 +2225,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, frame_data_cleanup(fdata); } - if (!wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header, - cf->pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame (cf, fdata, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cf->filename); break; @@ -2502,8 +2515,7 @@ process_specified_packets(capture_file *cf, packet_range_t *range, } /* Get the packet */ - if (!wtap_seek_read(cf->wth, fdata->file_off, &pseudo_header, - pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame_r(cf, fdata, &pseudo_header, pd, &err, &err_info)) { /* Attempt to get the packet failed. */ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cf->filename); @@ -3799,8 +3811,7 @@ find_packet(capture_file *cf, /* Is this packet in the display? */ if (fdata->flags.passed_dfilter) { /* Yes. Load its data. */ - if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header, - cf->pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame(cf, fdata, &err, &err_info)) { /* Read error. Report the error, and go back to the frame where we started. */ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, @@ -4031,8 +4042,7 @@ cf_select_packet(capture_file *cf, int row) } /* Get the data in that frame. */ - if (!wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header, - cf->pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame (cf, fdata, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cf->filename); return; diff --git a/file.h b/file.h index b546f3e86f..f4e51c7d5d 100644 --- a/file.h +++ b/file.h @@ -110,6 +110,13 @@ void cf_reload(capture_file *cf); */ cf_read_status_t cf_read(capture_file *cf, gboolean from_save); +gboolean cf_read_frame_r(capture_file *cf, frame_data *fdata, + union wtap_pseudo_header *pseudo_header, guint8 *pd, + int *err, gchar **err_info); + +gboolean cf_read_frame(capture_file *cf, frame_data *fdata, + int *err, gchar **err_info); + /** * Start reading from the end of a capture file. * This is used in "Update list of packets in Real-Time". diff --git a/gtk/iax2_analysis.c b/gtk/iax2_analysis.c index 4bd35c3356..2061e14d0a 100644 --- a/gtk/iax2_analysis.c +++ b/gtk/iax2_analysis.c @@ -3413,8 +3413,7 @@ static void iax2_analysis_cb(GtkWidget *w _U_, gpointer data _U_) return; /* if we exit here it's an error */ /* dissect the current frame */ - if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header, - cf->pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame(cf, fdata, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cf->filename); return; diff --git a/gtk/main.c b/gtk/main.c index 8cab7ee277..5548c52ae4 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -590,8 +590,7 @@ get_filter_from_packet_list_row_and_column(gpointer data) if (fdata != NULL) { epan_dissect_t edt; - if (!wtap_seek_read(cfile.wth, fdata->file_off, &cfile.pseudo_header, - cfile.pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame(&cfile, fdata, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cfile.filename); return NULL; diff --git a/gtk/packet_list_store.c b/gtk/packet_list_store.c index fae8f8bec9..269dae14d3 100644 --- a/gtk/packet_list_store.c +++ b/gtk/packet_list_store.c @@ -1097,8 +1097,7 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord * else cinfo = NULL; - if (!wtap_seek_read(cfile.wth, fdata->file_off, &pseudo_header, - pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame_r(&cfile, fdata, &pseudo_header, pd, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cfile.filename); return; diff --git a/gtk/packet_win.c b/gtk/packet_win.c index 2c5b7edfb8..a296f0a816 100644 --- a/gtk/packet_win.c +++ b/gtk/packet_win.c @@ -144,8 +144,7 @@ void new_window_cb(GtkWidget *w _U_) #ifdef NEW_PACKET_LIST /* With the new packetlists "lazy columns" it's neccesary to reread the frame */ - if (!wtap_seek_read(cfile.wth, cfile.current_frame->file_off, &cfile.pseudo_header, - cfile.pd, cfile.current_frame->cap_len, &err, &err_info)) { + if (!cf_read_frame(&cfile, cfile.current_frame, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cfile.filename); return; diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c index 1d0d4b8ab4..79d8288754 100644 --- a/gtk/rtp_analysis.c +++ b/gtk/rtp_analysis.c @@ -3636,8 +3636,7 @@ static void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_) return; /* if we exit here it's an error */ /* dissect the current frame */ - if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header, - cf->pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame(cf, fdata, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cf->filename); return; diff --git a/gtk/sctp_assoc_analyse.c b/gtk/sctp_assoc_analyse.c index 29e105a566..a74c49ddca 100644 --- a/gtk/sctp_assoc_analyse.c +++ b/gtk/sctp_assoc_analyse.c @@ -899,8 +899,7 @@ static void sctp_analyse_cb(struct sctp_analyse* u_data, gboolean ext) return; /* if we exit here it's an error */ /* dissect the current frame */ - if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header, - cf->pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame(cf, fdata, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cf->filename); return; diff --git a/gtk/tcp_graph.c b/gtk/tcp_graph.c index 5eb3db7ef6..45f09cbde9 100644 --- a/gtk/tcp_graph.c +++ b/gtk/tcp_graph.c @@ -1798,8 +1798,7 @@ static struct tcpheader *select_tcpip_session (capture_file *cf, struct segment } /* dissect the current frame */ - if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header, - cf->pd, fdata->cap_len, &err, &err_info)) { + if (!cf_read_frame(cf, fdata, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cf->filename); return NULL; diff --git a/proto_hier_stats.c b/proto_hier_stats.c index 75fb892472..e03cf8cdf1 100644 --- a/proto_hier_stats.c +++ b/proto_hier_stats.c @@ -149,8 +149,7 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) double cur_time; /* Load the frame from the capture file */ - if (!wtap_seek_read(cfile.wth, frame->file_off, &phdr, pd, - frame->cap_len, &err, &err_info)) { + if (!cf_read_frame_r(&cfile, frame, &phdr, pd, &err, &err_info)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, cf_read_error_message(err, err_info), cfile.filename); return FALSE; /* failure */