Turn around the sequence of PATH, so the former PATH will be in front of the newly...
[metze/wireshark/wip.git] / tap-mgcpstat.c
index 193b2d5135c60a8c4efab2b6084029e5d90da303..255970b7d49e2b23ba8f21608e7c77f4c3de97fd 100644 (file)
@@ -1,7 +1,7 @@
 /* tap-mgcpstat.c
  * mgcpstat   2003 Lars Roland
  *
- * $Id: tap-mgcpstat.c,v 1.6 2003/04/23 08:20:01 guy Exp $
+ * $Id$
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -34,7 +34,8 @@
 
 #include <string.h>
 #include "epan/packet_info.h"
-#include "tap.h"
+#include <epan/tap.h>
+#include <epan/stat_cmd_args.h>
 #include "epan/value_string.h"
 #include "register.h"
 #include "plugins/mgcp/packet-mgcp.h"
@@ -66,10 +67,10 @@ static const value_string mgcp_mesage_type[] = {
 };
 
 static int
-mgcpstat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, void *pmi)
+mgcpstat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pmi)
 {
        mgcpstat_t *ms=(mgcpstat_t *)pms;
-       mgcp_info_t *mi=pmi;
+       const mgcp_info_t *mi=pmi;
        nstime_t delta;
 
        switch (mi->mgcp_type) {
@@ -100,12 +101,7 @@ mgcpstat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, void *pm
                else {
                        ms->open_req_num--;
                        /* calculate time delta between request and response */
-                       delta.secs=pinfo->fd->abs_secs-mi->req_time.secs;
-                       delta.nsecs=pinfo->fd->abs_usecs*1000-mi->req_time.nsecs;
-                       if(delta.nsecs<0){
-                               delta.nsecs+=1000000000;
-                               delta.secs--;
-                       }
+                       nstime_delta(&delta, &pinfo->fd->abs_ts, &mi->req_time);
 
                        time_stat_update(&(ms->rtd[0]),&delta, pinfo);
 
@@ -181,18 +177,17 @@ mgcpstat_draw(void *pms)
 
 
 static void
-mgcpstat_init(char *optarg)
+mgcpstat_init(const char *optarg)
 {
        mgcpstat_t *ms;
        int i;
-       char *filter=NULL;
+       const char *filter=NULL;
        GString *error_string;
 
        if(!strncmp(optarg,"mgcp,rtd,",9)){
                filter=optarg+9;
        } else {
-               filter=g_malloc(1);
-               *filter='\0';
+               filter="";
        }
 
        ms=g_malloc(sizeof(mgcpstat_t));
@@ -233,6 +228,9 @@ mgcpstat_init(char *optarg)
 void
 register_tap_listener_mgcpstat(void)
 {
-       register_ethereal_tap("mgcp,rtd", mgcpstat_init);
+       /* We don't register this tap, if we don't have the mgcp plugin loaded.*/
+       if (find_tap_id("mgcp")) {
+               register_stat_cmd_arg("mgcp,rtd", mgcpstat_init);
+       }
 }