From 8022776680b476b3efc7602ce069a4de9087f5ef Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 6 Jan 2009 14:42:20 +0000 Subject: [PATCH] Disable MEGACO service response time statistics when context tracking is disabled. svn path=/trunk/; revision=27167 --- gtk/megaco_stat.c | 10 ++++++++++ tap-megaco-common.c | 8 +++++++- tap-megacostat.c | 12 +++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/gtk/megaco_stat.c b/gtk/megaco_stat.c index ab4022069f..e4d60d416f 100644 --- a/gtk/megaco_stat.c +++ b/gtk/megaco_stat.c @@ -42,6 +42,7 @@ #include #include #include "epan/gcp.h" +#include #include "../register.h" #include "../timestats.h" @@ -153,7 +154,16 @@ gtk_megacostat_init(const char *optarg, void *userdata _U_) GString *error_string; GtkWidget *bt_close; GtkWidget *bbox; + pref_t *megaco_ctx_track,*h248_ctx_track; + megaco_ctx_track = prefs_find_preference(prefs_find_module("megaco"),"ctx_info"); + h248_ctx_track = prefs_find_preference(prefs_find_module("h248"),"ctx_info"); + + if (!*megaco_ctx_track->varp.boolp || !*h248_ctx_track->varp.boolp) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", "Track Context option at Protocols -> MEGACO and Protocols -> H248 preferences has to be set to true to enable measurement of service reponse times."); + return; + } + if(strncmp(optarg,"megaco,srt,",11) == 0){ filter=optarg+11; } else { diff --git a/tap-megaco-common.c b/tap-megaco-common.c index f3ba4d4673..a6aa587436 100644 --- a/tap-megaco-common.c +++ b/tap-megaco-common.c @@ -119,7 +119,13 @@ megacostat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, const switch (mi->type) { GCP_CMD_REQ_CASE - if(mi->trx->initial->framenum != mi->msg->framenum){ + if(!mi->trx->initial) { + /* Track Context is probably disabled, we cannot + * measure service response time */ + return 0; + } + + else if(mi->trx->initial->framenum != mi->msg->framenum){ /* Duplicate is ignored */ ms->req_dup_num++; } diff --git a/tap-megacostat.c b/tap-megacostat.c index efd431ab4f..dfe9fdb92c 100644 --- a/tap-megacostat.c +++ b/tap-megacostat.c @@ -42,6 +42,7 @@ #include "register.h" #include "epan/gcp.h" #include "timestats.h" +#include #include "tap-megaco-common.h" @@ -84,7 +85,16 @@ megacostat_init(const char *optarg, void* userdata _U_) int i; const char *filter=NULL; GString *error_string; - + pref_t *megaco_ctx_track,*h248_ctx_track; + + megaco_ctx_track = prefs_find_preference(prefs_find_module("megaco"),"ctx_info"); + h248_ctx_track = prefs_find_preference(prefs_find_module("h248"),"ctx_info"); + if (!*megaco_ctx_track->varp.boolp || !*h248_ctx_track->varp.boolp) { + printf("Track Context option at Protocols -> MEGACO and Protocols -> H248 preferences\n"); + printf("has to be set to true to enable measurement of service reponse times.\n"); + exit(1); + } + if(!strncmp(optarg,"megaco,rtd,",11)){ filter=optarg+11; } else {