From Alexis La Goutte via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5768 :
[obnox/wireshark/wip.git] / tap-megacostat.c
index efd431ab4f935bb62ef91652327e528372096e5d..6e5186c688ea93b67c1dd632f3e211bdee56c5f9 100644 (file)
@@ -39,9 +39,9 @@
 #include <epan/tap.h>
 #include <epan/stat_cmd_args.h>
 #include "epan/value_string.h"
-#include "register.h"
 #include "epan/gcp.h"
 #include "timestats.h"
+#include <epan/prefs-int.h>
 
 #include "tap-megaco-common.h"
 
@@ -82,17 +82,29 @@ megacostat_init(const char *optarg, void* userdata _U_)
 {
        megacostat_t *ms;
        int i;
-       const char *filter=NULL;
        GString *error_string;
+       pref_t *megaco_ctx_track,*h248_ctx_track;
 
-       if(!strncmp(optarg,"megaco,rtd,",11)){
-               filter=optarg+11;
-       } else {
-               filter="";
+       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 || !h248_ctx_track) {
+               /* No such preferences */
+               return;
+       }
+
+       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 response times.\n");
+               exit(1);
        }
 
        ms=g_malloc(sizeof(megacostat_t));
-       ms->filter=g_strdup(filter);
+       if(!strncmp(optarg,"megaco,rtd,",11)){
+               ms->filter=g_strdup(optarg+11);
+       } else {
+               ms->filter=NULL;
+       }
 
        for(i=0;i<NUM_TIMESTATS;i++) {
                ms->rtd[i].num=0;
@@ -111,7 +123,7 @@ megacostat_init(const char *optarg, void* userdata _U_)
        ms->req_dup_num=0;
        ms->rsp_dup_num=0;
 
-       error_string=register_tap_listener("megaco", ms, filter, NULL, megacostat_packet, megacostat_draw);
+       error_string=register_tap_listener("megaco", ms, ms->filter, 0, NULL, megacostat_packet, megacostat_draw);
        if(error_string){
                /* error, we failed to attach to the tap. clean up */
                g_free(ms->filter);