diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-05-22 20:01:31 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-05-23 03:02:32 +0000 |
commit | c0c480d08c175eed4524ea9e73ec86298f468cf4 (patch) | |
tree | 1234cd09094dcc8447e3fb2b13671f12aba5ae69 /ui/qt/capture_file_dialog.cpp | |
parent | 6287efb9c05482531ea675bb5a3d23b03b5715ab (diff) |
Allow wtap_read() and wtap_seek_read() to return non-packet records.
This is the first step towards implementing the mechanisms requestd in
bug 8590; currently, we don't return any records other than packet
records from libwiretap, and just ignore non-packet records in the rest
of Wireshark, but this at least gets the ball rolling.
Change-Id: I34a45b54dd361f69fdad1a758d8ca4f42d67d574
Reviewed-on: https://code.wireshark.org/review/1736
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/qt/capture_file_dialog.cpp')
-rw-r--r-- | ui/qt/capture_file_dialog.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp index 03d4892411..3e123dc34b 100644 --- a/ui/qt/capture_file_dialog.cpp +++ b/ui/qt/capture_file_dialog.cpp @@ -736,11 +736,13 @@ void CaptureFileDialog::preview(const QString & path) wtap *wth; int err = 0; gchar *err_info; + int rec_type; gint64 data_offset; const struct wtap_pkthdr *phdr; double start_time = 0; /* seconds, with nsec resolution */ double stop_time = 0; /* seconds, with nsec resolution */ double cur_time; + unsigned int records = 0; unsigned int packets = 0; bool timed_out = FALSE; time_t time_preview; @@ -792,22 +794,25 @@ void CaptureFileDialog::preview(const QString & path) preview_size_.setText(QString(tr("%1 bytes")).arg(wtap_file_size(wth, &err))); time(&time_preview); - while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) { - phdr = wtap_phdr(wth); - cur_time = nstime_to_sec(&phdr->ts); - if(packets == 0) { - start_time = cur_time; - stop_time = cur_time; - } - if (cur_time < start_time) { - start_time = cur_time; - } - if (cur_time > stop_time){ - stop_time = cur_time; - } + while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) { + if (rec_type == REC_TYPE_PACKET) { + phdr = wtap_phdr(wth); + cur_time = nstime_to_sec(&phdr->ts); + if(packets == 0) { + start_time = cur_time; + stop_time = cur_time; + } + if (cur_time < start_time) { + start_time = cur_time; + } + if (cur_time > stop_time){ + stop_time = cur_time; + } - packets++; - if(packets%1000 == 0) { + packets++; + } + records++; + if(records%1000 == 0) { /* do we have a timeout? */ time(&time_current); if(time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) { |