From 92a1cdd4a412ffc3f9b5703001eb981212258bc9 Mon Sep 17 00:00:00 2001 From: Kovarththanan Rajaratnam Date: Sun, 20 Sep 2009 18:02:22 +0000 Subject: Use frame_data_init() instead of the locally defined fill_in_fdata(), which will be removed as part of this change svn path=/trunk/; revision=30022 --- rawshark.c | 81 +++++++++----------------------------------------------------- 1 file changed, 11 insertions(+), 70 deletions(-) diff --git a/rawshark.c b/rawshark.c index cd96ec313b..06b2f80ea6 100644 --- a/rawshark.c +++ b/rawshark.c @@ -121,6 +121,7 @@ */ static const gchar decode_as_arg_template[] = "==,"; +static guint32 cum_bytes = 0; static nstime_t first_ts; static nstime_t prev_dis_ts; static nstime_t prev_cap_ts; @@ -133,8 +134,8 @@ typedef enum { WRITE_XML /* PDML or PSML */ /* Add CSV and the like here */ } output_action_e; + static gboolean line_buffered; -static guint32 cum_bytes = 0; static print_format_e print_format = PR_FMT_TEXT; /* @@ -157,6 +158,13 @@ static void write_failure_message(const char *filename, int err); static void protocolinfo_init(char *field); static gboolean parse_field_string_format(char *format); +extern frame_data_init(frame_data *fdata, capture_file *cf, + const struct wtap_pkthdr *phdr, gint64 offset, + guint32 *cum_bytes, + nstime_t *first_ts, + nstime_t *prev_dis_ts, + nstime_t *prev_cap_ts); + typedef enum { SF_NONE, /* No format (placeholder) */ SF_NAME, /* %D Field name / description */ @@ -987,74 +995,6 @@ load_cap_file(capture_file *cf) return err; } -static void -fill_in_fdata(frame_data *fdata, capture_file *cf, - const struct wtap_pkthdr *phdr, gint64 offset) -{ - fdata->next = NULL; - fdata->prev = NULL; - fdata->pfd = NULL; - fdata->num = cf->count; - fdata->pkt_len = phdr->len; - cum_bytes += phdr->len; - fdata->cum_bytes = cum_bytes; - fdata->cap_len = phdr->caplen; - fdata->file_off = offset; - /* To save some memory, we coarcese it into a gint8 */ - g_assert(phdr->pkt_encap <= G_MAXINT8); - fdata->lnk_t = (gint8) phdr->pkt_encap; - fdata->abs_ts.secs = phdr->ts.secs; - fdata->abs_ts.nsecs = phdr->ts.nsecs; - fdata->flags.passed_dfilter = 0; - fdata->flags.encoding = CHAR_ASCII; - fdata->flags.visited = 0; - fdata->flags.marked = 0; - fdata->flags.ref_time = 0; - fdata->color_filter = NULL; - - /* If we don't have the time stamp of the first packet in the - capture, it's because this is the first packet. Save the time - stamp of this packet as the time stamp of the first packet. */ - if (nstime_is_unset(&first_ts)) { - first_ts = fdata->abs_ts; - } - - /* If we don't have the time stamp of the previous captured packet, - it's because this is the first packet. Save the time - stamp of this packet as the time stamp of the previous captured - packet. */ - if (nstime_is_unset(&prev_cap_ts)) { - prev_cap_ts = fdata->abs_ts; - } - - /* Get the time elapsed between the first packet and this packet. */ - nstime_delta(&fdata->rel_ts, &fdata->abs_ts, &first_ts); - - /* If it's greater than the current elapsed time, set the elapsed time - to it (we check for "greater than" so as not to be confused by - time moving backwards). */ - if ((gint32)cf->elapsed_time.secs < fdata->rel_ts.secs - || ((gint32)cf->elapsed_time.secs == fdata->rel_ts.secs && (gint32)cf->elapsed_time.nsecs < fdata->rel_ts.nsecs)) { - cf->elapsed_time = fdata->rel_ts; - } - - /* If we don't have the time stamp of the previous displayed packet, - it's because this is the first packet that's being displayed. Save the time - stamp of this packet as the time stamp of the previous displayed - packet. */ - if (nstime_is_unset(&prev_dis_ts)) - prev_dis_ts = fdata->abs_ts; - - /* Get the time elapsed between the previous displayed packet and - this packet. */ - nstime_delta(&fdata->del_dis_ts, &fdata->abs_ts, &prev_dis_ts); - - /* Get the time elapsed between the previous captured packet and - this packet. */ - nstime_delta(&fdata->del_cap_ts, &fdata->abs_ts, &prev_cap_ts); - prev_cap_ts = fdata->abs_ts; -} - /* Free up all data attached to a "frame_data" structure. */ static void clear_fdata(frame_data *fdata) @@ -1096,7 +1036,8 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, /* If we're going to print packet information, or we're going to run a read filter, or we're going to process taps, set up to do a dissection and do so. */ - fill_in_fdata(&fdata, cf, whdr, offset); + frame_data_init(&fdata, cf, whdr, offset, + &cum_bytes, &first_ts, &prev_dis_ts, &prev_cap_ts); passed = TRUE; create_proto_tree = TRUE; -- cgit v1.2.3