** (process:23326): WARNING **: Field 'Reserved bit(s)' does not have an
[obnox/wireshark/wip.git] / tap-afpstat.c
index bedee12f1ad39d0995c206b2b739b5cf6082c41a..0465decc6dc36a6de36eb86ee529e4955eabc19d 100644 (file)
@@ -4,8 +4,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
@@ -39,7 +39,6 @@
 #include <epan/stat_cmd_args.h>
 #include <epan/value_string.h>
 #include <epan/dissectors/packet-afp.h>
-#include "register.h"
 #include "timestats.h"
 
 /* used to keep track of the statistics for an entire program interface */
@@ -64,9 +63,8 @@ afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const voi
        sp=&(ss->proc[request_val->command]);
 
        /* calculate time delta between request and reply */
-       t.secs=pinfo->fd->abs_secs;
-       t.nsecs=pinfo->fd->abs_usecs*1000;
-       get_timedelta(&deltat, &t, &request_val->req_time);
+       t=pinfo->fd->abs_ts;
+       nstime_delta(&deltat, &t, &request_val->req_time);
 
        if(sp){
                time_stat_update(sp,&deltat, pinfo);
@@ -80,11 +78,7 @@ afpstat_draw(void *pss)
 {
        afpstat_t *ss=(afpstat_t *)pss;
        guint32 i;
-#ifdef G_HAVE_UINT64
        guint64 td;
-#else
-       guint32 td;
-#endif
        printf("\n");
        printf("===================================================================\n");
        printf("AFP RTT Statistics:\n");
@@ -97,8 +91,7 @@ afpstat_draw(void *pss)
                }
 
                /* scale it to units of 10us.*/
-               /* for long captures with a large tot time, this can overflow on 32bit */
-               td=(int)ss->proc[i].tot.secs;
+               td=ss->proc[i].tot.secs;
                td=td*100000+(int)ss->proc[i].tot.nsecs/10000;
                if(ss->proc[i].num){
                        td/=ss->proc[i].num;
@@ -106,8 +99,8 @@ afpstat_draw(void *pss)
                        td=0;
                }
 
-               printf("%-25s %6d %3d.%05d %3d.%05d %3d.%05d\n",
-                       val_to_str(i, CommandCode_vals, "Unknown (%u)"),
+               printf("%-25s %6d %3d.%05d %3d.%05d %3" G_GINT64_MODIFIER "u.%05" G_GINT64_MODIFIER "u\n",
+                       val_to_str_ext(i, &CommandCode_vals_ext, "Unknown (%u)"),
                        ss->proc[i].num,
                        (int)ss->proc[i].min.secs,ss->proc[i].min.nsecs/10000,
                        (int)ss->proc[i].max.secs,ss->proc[i].max.nsecs/10000,
@@ -119,7 +112,7 @@ afpstat_draw(void *pss)
 
 
 static void
-afpstat_init(const char *optarg)
+afpstat_init(const char *optarg, void* userdata _U_)
 {
        afpstat_t *ss;
        guint32 i;
@@ -134,8 +127,7 @@ afpstat_init(const char *optarg)
 
        ss=g_malloc(sizeof(afpstat_t));
        if(filter){
-               ss->filter=g_malloc(strlen(filter)+1);
-               strcpy(ss->filter, filter);
+               ss->filter=g_strdup(filter);
        } else {
                ss->filter=NULL;
        }
@@ -152,13 +144,13 @@ afpstat_init(const char *optarg)
                ss->proc[i].tot.nsecs=0;
        }
 
-       error_string=register_tap_listener("afp", ss, filter, NULL, afpstat_packet, afpstat_draw);
+       error_string=register_tap_listener("afp", ss, filter, 0, NULL, afpstat_packet, afpstat_draw);
        if(error_string){
                /* error, we failed to attach to the tap. clean up */
                g_free(ss->filter);
                g_free(ss);
 
-               fprintf(stderr, "tethereal: Couldn't register afp,rtt tap: %s\n",
+               fprintf(stderr, "tshark: Couldn't register afp,rtt tap: %s\n",
                    error_string->str);
                g_string_free(error_string, TRUE);
                exit(1);
@@ -168,5 +160,5 @@ afpstat_init(const char *optarg)
 void
 register_tap_listener_afpstat(void)
 {
-       register_stat_cmd_arg("afp,rtt", afpstat_init);
+       register_stat_cmd_arg("afp,rtt", afpstat_init,NULL);
 }