name change
[obnox/wireshark/wip.git] / gtk / io_stat.c
index bb5d6133a240ee9b3c877d2c7a6510ca23c5ab68..863e000c5dfffe593d30a38121a64a47282cfb77 100644 (file)
@@ -3,8 +3,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  * 
  * This program is free software; you can redistribute it and/or
@@ -44,7 +44,7 @@
 #include "gui_utils.h"
 #include <epan/stat_cmd_args.h>
 #include "../stat_menu.h"
-#include "gtk_stat_menu.h"
+#include "gui_stat_menu.h"
 #include <epan/tap.h>
 #include "../register.h"
 #include "alert_box.h"
@@ -197,12 +197,9 @@ io_stat_reset(io_stat_t *io)
                        ioi->int_max=0;
                        ioi->int_min=0;
                        ioi->int_tot=0;
-                       ioi->time_max.secs=0;
-                       ioi->time_max.nsecs=0;
-                       ioi->time_min.secs=0;
-                       ioi->time_min.nsecs=0;
-                       ioi->time_tot.secs=0;
-                       ioi->time_tot.nsecs=0;
+                       nstime_set_zero(&ioi->time_max);
+                       nstime_set_zero(&ioi->time_min);
+                       nstime_set_zero(&ioi->time_tot);
                }
        }
        io->last_interval=0xffffffff;
@@ -240,8 +237,7 @@ gtk_iostat_packet(void *g, packet_info *pinfo, epan_dissect_t *edt, const void *
         * Find which interval this is supposed to to in and store the
         * interval index as idx
         */
-       time_delta.secs=pinfo->fd->rel_secs;
-       time_delta.nsecs=pinfo->fd->rel_usecs*1000;
+       time_delta=pinfo->fd->rel_ts;
        if(time_delta.nsecs<0){
                time_delta.secs--;
                time_delta.nsecs+=1000000000;
@@ -328,7 +324,7 @@ gtk_iostat_packet(void *g, packet_info *pinfo, epan_dissect_t *edt, const void *
                                        t=t*1000000+new_time->nsecs/1000;
                                        i=idx;
                                        /* handle current interval */
-                                       pt=pinfo->fd->rel_secs*1000000+pinfo->fd->rel_usecs;
+                                       pt=pinfo->fd->rel_ts.secs*1000000+pinfo->fd->rel_ts.nsecs/1000;
                                        pt=pt%(git->io->interval*1000);
                                        if(pt>t){
                                                pt=t;
@@ -357,22 +353,15 @@ gtk_iostat_packet(void *g, packet_info *pinfo, epan_dissect_t *edt, const void *
                                        ||( (new_time->secs==it->time_max.secs)
                                          &&(new_time->nsecs>it->time_max.nsecs))
                                        ||(it->frames==0)){
-                                               it->time_max.secs=new_time->secs;
-                                               it->time_max.nsecs=new_time->nsecs;
+                                               it->time_max=*new_time;
                                        }
                                        if( (new_time->secs<it->time_min.secs)
                                        ||( (new_time->secs==it->time_min.secs)
                                          &&(new_time->nsecs<it->time_min.nsecs))
                                        ||(it->frames==0)){
-                                               it->time_min.secs=new_time->secs;
-                                               it->time_min.nsecs=new_time->nsecs;
-                                       }
-                                       it->time_tot.secs+=new_time->secs;
-                                       it->time_tot.nsecs+=new_time->nsecs;
-                                       if(it->time_tot.nsecs>=1000000000){
-                                               it->time_tot.nsecs-=1000000000;
-                                               it->time_tot.secs++;
+                                               it->time_min=*new_time;
                                        }
+                                       nstime_add(&it->time_tot, new_time);
                                }
 
                        }
@@ -897,20 +886,16 @@ io_stat_draw(io_stat_t *io)
                                y_pos=draw_height-1-(val*draw_height)/max_y+top_y_border;
                        }
 
-                       /* dont need to draw anything if the segment
-                        * is entirely above the top of the graph 
-                        */
-                       if( (prev_y_pos==0) && (y_pos==0) ){
-                               prev_y_pos=y_pos;
-                               prev_x_pos=x_pos;
-                               continue;
-                       }
-
                        switch(io->graphs[i].plot_style){
                        case PLOT_STYLE_LINE:
-                               gdk_draw_line(io->pixmap, io->graphs[i].gc, 
-                                       prev_x_pos, prev_y_pos, 
-                                       x_pos, y_pos);
+                               /* dont need to draw anything if the segment
+                                * is entirely above the top of the graph
+                                */
+                               if( (prev_y_pos!=0) || (y_pos!=0) ){
+                                       gdk_draw_line(io->pixmap, io->graphs[i].gc,
+                                               prev_x_pos, prev_y_pos,
+                                               x_pos, y_pos);
+                               }
                                break;
                        case PLOT_STYLE_IMPULSE:
                                if(val){
@@ -1050,7 +1035,7 @@ disable_graph(io_stat_graph_t *gio)
 }
 
 static void
-gtk_iostat_init(const char *optarg _U_)
+gtk_iostat_init(const char *optarg _U_, void* userdata _U_)
 {
        io_stat_t *io;
        int i=0;
@@ -1096,6 +1081,7 @@ gtk_iostat_init(const char *optarg _U_)
                io->graphs[i].args->title = NULL;
                io->graphs[i].args->wants_apply_button=TRUE;
                io->graphs[i].args->activate_on_ok=TRUE;
+               io->graphs[i].args->modal_and_transient=FALSE;
 
                io->graphs[i].filter_bt=NULL;
        }
@@ -1116,7 +1102,7 @@ gtk_iostat_init(const char *optarg _U_)
        /* build the GUI */
        init_io_stat_window(io);
 
-       cf_retap_packets(&cfile);
+       cf_retap_packets(&cfile, FALSE);
        io_stat_redraw(io);
 }
 
@@ -1276,7 +1262,7 @@ tick_interval_select(GtkWidget *item, gpointer key)
        val=(int)OBJECT_GET_DATA(item, "tick_interval");
 
        io->interval=val;
-       cf_retap_packets(&cfile);
+       cf_retap_packets(&cfile, FALSE);
        io_stat_redraw(io);
 }
 
@@ -1539,7 +1525,7 @@ filter_callback(GtkWidget *widget _U_, io_stat_graph_t *gio)
                /* warn and bail out if the field could not be found */
                hfi=proto_registrar_get_byname(field);
                if(hfi==NULL){
-                       simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "'%s' isn't a valid field name.", field);
+                       simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "There is no field named '%s'.", field);
                        disable_graph(gio);
                        io_stat_redraw(gio->io);
                        return 0;
@@ -1641,7 +1627,7 @@ filter_callback(GtkWidget *widget _U_, io_stat_graph_t *gio)
        
        io_stat_reset(gio->io);
        enable_graph(gio, filter, field);
-       cf_retap_packets(&cfile);
+       cf_retap_packets(&cfile, FALSE);
        io_stat_redraw(gio->io);
 
        return 0;
@@ -1928,7 +1914,7 @@ init_io_stat_window(io_stat_t *io)
 static void 
 gtk_iostat_cb(GtkWidget *w _U_, gpointer d _U_)
 {
-       gtk_iostat_init(NULL);
+       gtk_iostat_init(NULL,NULL);
 }
 
 
@@ -1937,7 +1923,7 @@ gtk_iostat_cb(GtkWidget *w _U_, gpointer d _U_)
 void
 register_tap_listener_gtk_iostat(void)
 {
-       register_stat_cmd_arg("io,stat", gtk_iostat_init);
+       register_stat_cmd_arg("io,stat", gtk_iostat_init,NULL);
 
        register_stat_menu_item("_IO Graphs", REGISTER_STAT_GROUP_GENERIC,
         gtk_iostat_cb, NULL, NULL, NULL);