Update:
[obnox/wireshark/wip.git] / tap-megaco-common.c
index f3ba4d46731204fd9bd7ffa4facaadab8db109b3..03ffeb7660895eb6fabac2759d711129b4ca88fe 100644 (file)
@@ -41,9 +41,7 @@
 #include <epan/tap.h>
 #include "epan/gcp.h"
 
-#include "../register.h"
 #include "../timestats.h"
-#include "../simple_dialog.h"
 #include "../file.h"
 #include "../globals.h"
 #include "../stat_menu.h"
@@ -59,12 +57,13 @@ megacostat_is_duplicate_reply(const gcp_cmd_t* cmd)
                {
                        gcp_cmd_msg_t *cmd_msg;
                        /* cycle through commands to find same command in the transaction */
-                       for (cmd_msg = cmd->trx->cmds; cmd_msg->cmd->msg->framenum != cmd->msg->framenum &&
-                                       cmd_msg != NULL; cmd_msg = cmd_msg->next) {
+                       for (cmd_msg = cmd->trx->cmds;
+                            (cmd_msg != NULL) && (cmd_msg->cmd->msg->framenum != cmd->msg->framenum);
+                            cmd_msg = cmd_msg->next) {
                                if (cmd_msg->cmd->type == cmd->type)
                                        return TRUE;
                        }
-                               
+
                        return FALSE;
                }
                break;
@@ -73,7 +72,7 @@ megacostat_is_duplicate_reply(const gcp_cmd_t* cmd)
                break;
        }
 
-       
+
 }
 
 static gboolean
@@ -85,9 +84,10 @@ megacostat_had_request(const gcp_cmd_t* cmd)
                {
                        gcp_cmd_msg_t *cmd_msg;
                        /* cycle through commands to find a request in the transaction */
-                       for (cmd_msg = cmd->trx->cmds; cmd_msg->cmd->msg->framenum != cmd->msg->framenum &&
-                                       cmd_msg != NULL; cmd_msg = cmd_msg->next) {
-                               
+                       for (cmd_msg = cmd->trx->cmds;
+                            (cmd_msg != NULL) && (cmd_msg->cmd->msg->framenum != cmd->msg->framenum);
+                            cmd_msg = cmd_msg->next) {
+
                                switch (cmd_msg->cmd->type) {
 
                                GCP_CMD_REQ_CASE
@@ -98,7 +98,7 @@ megacostat_had_request(const gcp_cmd_t* cmd)
                                        break;
                                }
                        }
-                               
+
                        return FALSE;
                }
                break;
@@ -112,14 +112,20 @@ int
 megacostat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pmi)
 {
        megacostat_t *ms=(megacostat_t *)pms;
-       const gcp_cmd_t *mi=(gcp_cmd_t*)pmi;
+       const gcp_cmd_t *mi=(const gcp_cmd_t*)pmi;
        nstime_t delta;
        int ret = 0;
 
        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++;
                }
@@ -143,7 +149,7 @@ megacostat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, const
                        nstime_delta(&delta, &pinfo->fd->abs_ts, &mi->trx->initial->time);
 
                        switch(mi->type) {
-                       
+
                        case GCP_CMD_ADD_REPLY:
                                time_stat_update(&(ms->rtd[0]),&delta, pinfo);
                                break;