aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-04-18 22:05:56 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-04-18 22:05:56 +0000
commit7ee0db108058625bbea758f20373db0df32c2613 (patch)
tree253fc99732b4bb575935f068018ed6ab36e82d44
parent207fcef3131d7b4f6a5dcb4889e78870da21c6a1 (diff)
statusbar changes:
-show the current capture file size, if capturing in real time mode. -move the packet "Drops" count (if available) from file to packets statusbar part svn path=/trunk/; revision=14130
-rw-r--r--capture.c6
-rw-r--r--file.c15
-rw-r--r--file.h3
-rw-r--r--gtk/main.c57
4 files changed, 49 insertions, 32 deletions
diff --git a/capture.c b/capture.c
index 4e21495edf..f9f6788af8 100644
--- a/capture.c
+++ b/capture.c
@@ -278,6 +278,7 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
file.
XXX - abort on a read error? */
+ cf_callback_invoke(cf_cb_live_capture_update_continue, capture_opts->cf);
main_window_update();
break;
@@ -308,10 +309,7 @@ capture_input_closed(capture_options *capture_opts)
}
if(capture_opts->real_time_mode) {
- /* first of all, update the file length field */
- cf_update_f_len(capture_opts->cf);
-
- /* we are not doing a capture any more */
+ /* first of all, we are not doing a capture any more */
cf_callback_invoke(cf_cb_live_capture_update_finished, capture_opts->cf);
/* Read what remains of the capture file, and finish the capture.
diff --git a/file.c b/file.c
index f4055d7ed9..dd624f8771 100644
--- a/file.c
+++ b/file.c
@@ -625,20 +625,6 @@ cf_finish_tail(capture_file *cf, int *err)
}
#endif /* HAVE_LIBPCAP */
-
-/* update the f_len field */
-cf_update_f_len(capture_file *cf) {
- int fd;
- struct stat cf_stat;
-
-
- fd = wtap_fd(cf->wth);
- if (fstat(fd, &cf_stat) >= 0) {
- cf->f_len = cf_stat.st_size;
- }
-}
-
-
const gchar *
cf_get_display_name(capture_file *cf)
{
@@ -908,6 +894,7 @@ read_packet(capture_file *cf, long offset)
cf->plist_end = fdata;
cf->count++;
+ cf->f_len = offset + phdr->caplen;
fdata->num = cf->count;
add_packet_to_packet_list(fdata, cf, pseudo_header, buf, TRUE);
} else {
diff --git a/file.h b/file.h
index da9277f327..74cc6981b6 100644
--- a/file.h
+++ b/file.h
@@ -61,8 +61,9 @@ typedef enum {
cf_cb_file_read_finished,
#ifdef HAVE_LIBPCAP
cf_cb_live_capture_update_started,
- cf_cb_live_capture_fixed_started,
+ cf_cb_live_capture_update_continue,
cf_cb_live_capture_update_finished,
+ cf_cb_live_capture_fixed_started,
cf_cb_live_capture_fixed_finished,
#endif
cf_cb_packet_selected,
diff --git a/gtk/main.c b/gtk/main.c
index 9447b6a992..31dbd842f6 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -846,8 +846,13 @@ void packets_bar_update(void)
/* do we have any packets? */
if(cfile.count) {
- packets_str = g_strdup_printf(" P: %u D: %u M: %u",
- cfile.count, cfile.displayed_count, cfile.marked_count);
+ if(cfile.drops_known) {
+ packets_str = g_strdup_printf(" P: %u D: %u M: %u Drops: %u",
+ cfile.count, cfile.displayed_count, cfile.marked_count, cfile.drops);
+ } else {
+ packets_str = g_strdup_printf(" P: %u D: %u M: %u",
+ cfile.count, cfile.displayed_count, cfile.marked_count);
+ }
} else {
packets_str = g_strdup(" No Packets");
}
@@ -1181,8 +1186,7 @@ set_display_filename(capture_file *cf)
{
const gchar *name_ptr;
size_t msg_len;
- static const gchar done_fmt_nodrops[] = " File: %s %s %02u:%02u:%02u";
- static const gchar done_fmt_drops[] = " File: %s %s %02u:%02u:%02u Drops: %u";
+ static const gchar done_fmt[] = " File: %s %s %02u:%02u:%02u";
gchar *done_msg;
gchar *win_name_fmt = "%s - Ethereal";
gchar *win_name;
@@ -1200,16 +1204,11 @@ set_display_filename(capture_file *cf)
} else if (cf->f_len/1024 > 10) {
size_str = g_strdup_printf("%ld KB", cf->f_len/1024);
} else {
- size_str = g_strdup_printf("%ld bytes", cf->f_len);
+ size_str = g_strdup_printf("%ld Bytes", cf->f_len);
}
- if (cf->drops_known) {
- done_msg = g_strdup_printf(done_fmt_drops, name_ptr, size_str,
- cf->esec/3600, cf->esec%3600/60, cf->esec%60, cf->drops);
- } else {
- done_msg = g_strdup_printf(done_fmt_nodrops, name_ptr, size_str,
- cf->esec/3600, cf->esec%3600/60, cf->esec%60);
- }
+ done_msg = g_strdup_printf(done_fmt, name_ptr, size_str,
+ cf->esec/3600, cf->esec%3600/60, cf->esec%60);
g_free(size_str);
statusbar_push_file_msg(done_msg);
g_free(done_msg);
@@ -1305,7 +1304,8 @@ main_cf_cb_live_capture_update_started(capture_options *capture_opts)
set_menus_for_captured_packets(TRUE);
capture_msg = g_strdup_printf(" %s: <live capture in progress> to file: %s",
- get_interface_descriptive_name(capture_opts->iface), capture_opts->save_file);
+ get_interface_descriptive_name(capture_opts->iface),
+ (capture_opts->save_file) ? capture_opts->save_file : "");
statusbar_push_file_msg(capture_msg);
@@ -1316,6 +1316,34 @@ main_cf_cb_live_capture_update_started(capture_options *capture_opts)
}
static void
+main_cf_cb_live_capture_update_continue(capture_file *cf)
+{
+ gchar *capture_msg;
+
+
+ statusbar_pop_file_msg();
+
+ if (cf->f_len/1024/1024 > 10) {
+ capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %ld MB",
+ get_interface_descriptive_name(capture_opts->iface),
+ capture_opts->save_file,
+ cf->f_len/1024/1024);
+ } else if (cf->f_len/1024 > 10) {
+ capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %ld KB",
+ get_interface_descriptive_name(capture_opts->iface),
+ capture_opts->save_file,
+ cf->f_len/1024);
+ } else {
+ capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %ld Bytes",
+ get_interface_descriptive_name(capture_opts->iface),
+ capture_opts->save_file,
+ cf->f_len);
+ }
+
+ statusbar_push_file_msg(capture_msg);
+}
+
+static void
main_cf_cb_live_capture_update_finished(capture_file *cf)
{
/* Pop the "<live capture in progress>" message off the status bar. */
@@ -1471,6 +1499,9 @@ void main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
case(cf_cb_live_capture_update_started):
main_cf_cb_live_capture_update_started(data);
break;
+ case(cf_cb_live_capture_update_continue):
+ main_cf_cb_live_capture_update_continue(data);
+ break;
case(cf_cb_live_capture_fixed_started):
main_cf_cb_live_capture_fixed_started(data);
break;