/* 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>
#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"
};
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) {
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);
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));
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);
+ }
}