summaryrefslogtreecommitdiff
path: root/tshark.c
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-20 17:51:16 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-20 17:51:16 +0000
commite56f27dc99ebd3cb790f156c538092c2e5d704a3 (patch)
treeb998cc45218cbe61b17f804e1b04311412d8c4b0 /tshark.c
parent6691a701e3f56bb4871e6ef6bacf52e661581e59 (diff)
downloadwireshark-e56f27dc99ebd3cb790f156c538092c2e5d704a3.tar.gz
Introduce frame_data_init() and get rid of fill_in_fdata() in tshark.c
svn path=/trunk/; revision=30021
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c83
1 files changed, 13 insertions, 70 deletions
diff --git a/tshark.c b/tshark.c
index 3b66c4a40d..11387b0b85 100644
--- a/tshark.c
+++ b/tshark.c
@@ -105,9 +105,11 @@
*/
static const gchar decode_as_arg_template[] = "<layer_type>==<selector>,<decode_as_protocol>";
+static guint32 cum_bytes;
static nstime_t first_ts;
static nstime_t prev_dis_ts;
static nstime_t prev_cap_ts;
+
static gboolean print_packet_info; /* TRUE if we're to print packet information */
/*
@@ -119,12 +121,13 @@ typedef enum {
WRITE_FIELDS /* User defined list of fields */
/* Add CSV and the like here */
} output_action_e;
+
static output_action_e output_action;
static gboolean do_dissection; /* TRUE if we have to dissect each packet */
static gboolean verbose;
static gboolean print_hex;
static gboolean line_buffered;
-static guint32 cum_bytes = 0;
+
static print_format_e print_format = PR_FMT_TEXT;
static print_stream_t *print_stream;
@@ -180,6 +183,13 @@ static void failure_message(const char *msg_format, va_list ap);
static void read_failure_message(const char *filename, int err);
static void write_failure_message(const char *filename, int err);
+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);
+
capture_file cfile;
void
@@ -2326,74 +2336,6 @@ out:
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)
@@ -2420,7 +2362,8 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
run a read filter, or we're going to process taps, set up to
do a dissection and do so. */
if (do_dissection) {
- fill_in_fdata(&fdata, cf, whdr, offset);
+ frame_data_init(&fdata, cf, whdr, offset,
+ &cum_bytes, &first_ts, &prev_dis_ts, &prev_cap_ts);
if (print_packet_info) {
/* Grab any resolved addresses */