Update to V9.0.0 (2009-12)
[obnox/wireshark/wip.git] / tap-sipstat.c
index 0862c4152df610a028bdfc6057c29069031962b5..e3b281c93875ab30633cf377530463f4494a5e5c 100644 (file)
@@ -46,6 +46,11 @@ typedef struct _sip_stats_t {
        char            *filter;
        guint32         packets;        /* number of sip packets, including continuations */
        guint32         resent_packets;
+       guint32         average_setup_time;
+       guint32         max_setup_time;
+       guint32         min_setup_time;
+       guint32         no_of_completed_calls;
+       guint64         total_setup_time;
        GHashTable      *hash_responses;
        GHashTable      *hash_requests;
 } sipstat_t;
@@ -104,6 +109,7 @@ static const value_string vals_status_code[] = {
     { 416, "Unsupported URI Scheme"},
     { 420, "Bad Extension"},
     { 421, "Extension Required"},
+    { 422, "Session Timer Too Small"},
     { 423, "Interval Too Brief"},
     { 429, "Provide Referrer Identity"},
     { 480, "Temporarily Unavailable"},
@@ -213,6 +219,12 @@ sipstat_reset(void *psp  )
        if (sp) {
                sp->packets = 0;
                sp->resent_packets = 0;
+               sp->average_setup_time = 0;
+               sp->max_setup_time = 0;
+               sp->min_setup_time = 0;
+               sp->no_of_completed_calls = 0;
+               sp->total_setup_time = 0;
+
                g_hash_table_foreach( sp->hash_responses, (GHFunc)sip_reset_hash_responses, NULL);
                g_hash_table_foreach( sp->hash_requests, (GHFunc)sip_reset_hash_requests, NULL);
        }
@@ -228,6 +240,28 @@ sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const
     
     /* Total number of packets, including continuation packets */
     sp->packets++;
+
+       /* Calculate average setup time */
+       if (value->setup_time){
+               sp->no_of_completed_calls++;
+               /* Check if it's the first value */
+               if ( sp->total_setup_time == 0 ){
+                       sp->average_setup_time = value->setup_time;
+                       sp->total_setup_time = value->setup_time;
+                       sp->max_setup_time = value->setup_time;
+                       sp->min_setup_time = value->setup_time;
+               }else{
+                       sp->total_setup_time = sp->total_setup_time + value->setup_time;
+                       if (sp->max_setup_time < value->setup_time){
+                               sp->max_setup_time = value->setup_time;
+                       }
+                       if (sp->min_setup_time > value->setup_time){
+                               sp->min_setup_time = value->setup_time;
+                       }
+                       /* Calculate average */
+                       sp->average_setup_time = (guint32)(sp->total_setup_time / sp->no_of_completed_calls); 
+               }
+       }
     
     /* Update resent count if flag set */
     if (value->resend)
@@ -344,6 +378,7 @@ sipstat_draw(void *psp  )
        printf("\n* List of SIP Request methods\n");
        g_hash_table_foreach( sp->hash_requests,  (GHFunc)sip_draw_hash_requests,
                "  %-15s : %5d Packets\n");
+       printf( "\n* Average setup time %d ms\n Min %d ms\n Max %d ms\n", sp->average_setup_time, sp->min_setup_time, sp->max_setup_time);
        printf("===================================================================\n");
 }
 
@@ -373,6 +408,7 @@ sipstat_init(const char *optarg, void* userdata _U_)
                        "sip",
                        sp,
                        filter,
+                       0,
                        sipstat_reset,
                        sipstat_packet,
                        sipstat_draw);