aboutsummaryrefslogtreecommitdiffstats
path: root/capinfos.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2007-01-28 17:33:14 +0000
committerBill Meier <wmeier@newsguy.com>2007-01-28 17:33:14 +0000
commit30dd4b8dda8363d59310c949367cb16aadd2e728 (patch)
tree934563e1cff821c1327ec46fe4b33a582a1e6208 /capinfos.c
parent88e699977cb5cb01bea4b164da3f874e4e603241 (diff)
If no packets in input file then don't calc packets/sec, etc
svn path=/trunk/; revision=20587
Diffstat (limited to 'capinfos.c')
-rw-r--r--capinfos.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/capinfos.c b/capinfos.c
index 4e6b7ca530..1b6ff6a6bb 100644
--- a/capinfos.c
+++ b/capinfos.c
@@ -105,8 +105,8 @@ print_stats(capture_info *cf_info)
if (cap_file_size) printf("File size: %" PRId64 " bytes\n", cf_info->filesize);
if (cap_data_size) printf("Data size: %" PRIu64 " bytes\n", cf_info->packet_bytes);
if (cap_duration) printf("Capture duration: %f seconds\n", cf_info->duration);
- if (cap_start_time) printf("Start time: %s", ctime (&start_time_t));
- if (cap_end_time) printf("End time: %s", ctime (&stop_time_t));
+ if (cap_start_time) printf("Start time: %s", (cf_info->packet_count>0) ? ctime (&start_time_t) : "n/a\n");
+ if (cap_end_time) printf("End time: %s", (cf_info->packet_count>0) ? ctime (&stop_time_t) : "n/a\n");
if (cap_data_rate_byte) printf("Data rate: %.2f bytes/s\n", cf_info->data_rate);
if (cap_data_rate_bit) printf("Data rate: %.2f bits/s\n", cf_info->data_rate*8);
if (cap_packet_size) printf("Average packet size: %.2f bytes\n", cf_info->packet_size);
@@ -186,11 +186,14 @@ process_cap_file(wtap *wth, const char *filename)
/* Number of packet bytes */
cf_info.packet_bytes = bytes;
- /* Data rate per second */
- cf_info.data_rate = (double)bytes / (stop_time-start_time);
-
- /* Avg packet size */
- cf_info.packet_size = (double)bytes/packet;
+ if (packet > 0) {
+ cf_info.data_rate = (double)bytes / (stop_time-start_time); /* Data rate per second */
+ cf_info.packet_size = (double)bytes / packet; /* Avg packet size */
+ }
+ else {
+ cf_info.data_rate = 0.0;
+ cf_info.packet_size = 0.0;
+ }
printf("File name: %s\n", filename);
print_stats(&cf_info);