forked from osmocom/wireshark
Use consistent indentation and formatting style;
Fix a few typos; Fix long line. svn path=/trunk/; revision=44902
This commit is contained in:
parent
ebda6f06b7
commit
dd7a2708be
1 changed files with 134 additions and 132 deletions
|
@ -46,32 +46,32 @@
|
||||||
|
|
||||||
#include "ui/gtk/old-gtk-compat.h"
|
#include "ui/gtk/old-gtk-compat.h"
|
||||||
|
|
||||||
#define SUM_STR_MAX 1024
|
#define SUM_STR_MAX 1024
|
||||||
|
|
||||||
/* Used to keep track of the statistics for an entire program interface */
|
/* Used to keep track of the statistics for an entire program interface */
|
||||||
typedef struct _sip_stats_t {
|
typedef struct _sip_stats_t {
|
||||||
char *filter;
|
char *filter;
|
||||||
GtkWidget *win;
|
GtkWidget *win;
|
||||||
GHashTable *hash_responses;
|
GHashTable *hash_responses;
|
||||||
GHashTable *hash_requests;
|
GHashTable *hash_requests;
|
||||||
guint32 packets; /* number of sip packets, including continuations */
|
guint32 packets; /* number of sip packets, including continuations */
|
||||||
guint32 resent_packets;
|
guint32 resent_packets;
|
||||||
guint32 average_setup_time;
|
guint32 average_setup_time;
|
||||||
guint32 max_setup_time;
|
guint32 max_setup_time;
|
||||||
guint32 min_setup_time;
|
guint32 min_setup_time;
|
||||||
guint32 no_of_completed_calls;
|
guint32 no_of_completed_calls;
|
||||||
guint64 total_setup_time;
|
guint64 total_setup_time;
|
||||||
GtkWidget *packets_label;
|
GtkWidget *packets_label;
|
||||||
GtkWidget *resent_label;
|
GtkWidget *resent_label;
|
||||||
GtkWidget *average_setup_time_label;
|
GtkWidget *average_setup_time_label;
|
||||||
|
|
||||||
GtkWidget *request_box; /* container for INVITE, ... */
|
GtkWidget *request_box; /* container for INVITE, ... */
|
||||||
|
|
||||||
GtkWidget *informational_table; /* Status code between 100 and 199 */
|
GtkWidget *informational_table; /* Status code between 100 and 199 */
|
||||||
GtkWidget *success_table; /* 200 and 299 */
|
GtkWidget *success_table; /* 200 and 299 */
|
||||||
GtkWidget *redirection_table; /* 300 and 399 */
|
GtkWidget *redirection_table; /* 300 and 399 */
|
||||||
GtkWidget *client_error_table; /* 400 and 499 */
|
GtkWidget *client_error_table; /* 400 and 499 */
|
||||||
GtkWidget *server_errors_table; /* 500 and 599 */
|
GtkWidget *server_errors_table; /* 500 and 599 */
|
||||||
GtkWidget *global_failures_table; /* 600 and 699 */
|
GtkWidget *global_failures_table; /* 600 and 699 */
|
||||||
} sipstat_t;
|
} sipstat_t;
|
||||||
|
|
||||||
|
@ -79,21 +79,21 @@ typedef struct _sip_stats_t {
|
||||||
* for example it can be { 3, 404, "Not Found" ,...}
|
* for example it can be { 3, 404, "Not Found" ,...}
|
||||||
* which means we captured 3 reply sip/1.1 404 Not Found */
|
* which means we captured 3 reply sip/1.1 404 Not Found */
|
||||||
typedef struct _sip_response_code_t {
|
typedef struct _sip_response_code_t {
|
||||||
guint32 packets; /* 3 */
|
guint32 packets; /* 3 */
|
||||||
guint response_code; /* 404 */
|
guint response_code; /* 404 */
|
||||||
const gchar *name; /* "Not Found" */
|
const gchar *name; /* "Not Found" */
|
||||||
GtkWidget *widget; /* Label where we display it */
|
GtkWidget *widget; /* Label where we display it */
|
||||||
GtkWidget *table; /* Table in which we put it,
|
GtkWidget *table; /* Table in which we put it,
|
||||||
e.g. client_error_table */
|
e.g. client_error_table */
|
||||||
sipstat_t *sp; /* Pointer back to main struct */
|
sipstat_t *sp; /* Pointer back to main struct */
|
||||||
} sip_response_code_t;
|
} sip_response_code_t;
|
||||||
|
|
||||||
/* Used to keep track of the stats for a specific request string */
|
/* Used to keep track of the stats for a specific request string */
|
||||||
typedef struct _sip_request_method_t {
|
typedef struct _sip_request_method_t {
|
||||||
gchar *response; /* eg. : INVITE */
|
gchar *response; /* eg. : INVITE */
|
||||||
guint32 packets;
|
guint32 packets;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
sipstat_t *sp; /* Pointer back to main struct */
|
sipstat_t *sp; /* Pointer back to main struct */
|
||||||
} sip_request_method_t;
|
} sip_request_method_t;
|
||||||
|
|
||||||
/* TODO: extra codes to be added from SIP extensions? */
|
/* TODO: extra codes to be added from SIP extensions? */
|
||||||
|
@ -108,7 +108,7 @@ static const value_string vals_status_code[] = {
|
||||||
{ 200, "OK"},
|
{ 200, "OK"},
|
||||||
{ 202, "Accepted"},
|
{ 202, "Accepted"},
|
||||||
{ 204, "No Notification"},
|
{ 204, "No Notification"},
|
||||||
{ 299, "Success - Others"}, /* used to keep track of other Success packets */
|
{ 299, "Success - Others"}, /* used to keep track of other Success packets */
|
||||||
|
|
||||||
{ 300, "Multiple Choices"},
|
{ 300, "Multiple Choices"},
|
||||||
{ 301, "Moved Permanently"},
|
{ 301, "Moved Permanently"},
|
||||||
|
@ -176,7 +176,7 @@ static const value_string vals_status_code[] = {
|
||||||
{ 606, "Not Acceptable"},
|
{ 606, "Not Acceptable"},
|
||||||
{ 699, "Global Failure - Others"},
|
{ 699, "Global Failure - Others"},
|
||||||
|
|
||||||
{ 0, NULL}
|
{ 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
void register_tap_listener_gtksipstat(void);
|
void register_tap_listener_gtksipstat(void);
|
||||||
|
@ -194,15 +194,16 @@ sip_init_hash(sipstat_t *sp)
|
||||||
/* Add all response codes */
|
/* Add all response codes */
|
||||||
for (i=0 ; vals_status_code[i].strptr ; i++)
|
for (i=0 ; vals_status_code[i].strptr ; i++)
|
||||||
{
|
{
|
||||||
gint *key = g_malloc (sizeof(gint));
|
gint *key = g_malloc (sizeof(gint));
|
||||||
sip_response_code_t *sc = g_malloc (sizeof(sip_response_code_t));
|
sip_response_code_t *sc = g_malloc (sizeof(sip_response_code_t));
|
||||||
*key = vals_status_code[i].value;
|
|
||||||
sc->packets=0;
|
*key = vals_status_code[i].value;
|
||||||
sc->response_code = *key;
|
sc->packets = 0;
|
||||||
sc->name=vals_status_code[i].strptr;
|
sc->response_code = *key;
|
||||||
sc->widget=NULL;
|
sc->name = vals_status_code[i].strptr;
|
||||||
sc->table=NULL;
|
sc->widget = NULL;
|
||||||
sc->sp = sp;
|
sc->table = NULL;
|
||||||
|
sc->sp = sp;
|
||||||
g_hash_table_insert(sc->sp->hash_responses, key, sc);
|
g_hash_table_insert(sc->sp->hash_responses, key, sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,13 +213,13 @@ sip_init_hash(sipstat_t *sp)
|
||||||
|
|
||||||
/* Draw the entry for an individual request message */
|
/* Draw the entry for an individual request message */
|
||||||
static void
|
static void
|
||||||
sip_draw_hash_requests(gchar *key _U_ , sip_request_method_t *data, gchar * unused _U_)
|
sip_draw_hash_requests(gchar *key _U_, sip_request_method_t *data, gchar *unused _U_)
|
||||||
{
|
{
|
||||||
gchar string_buff[SUM_STR_MAX];
|
gchar string_buff[SUM_STR_MAX];
|
||||||
|
|
||||||
g_assert(data!=NULL);
|
g_assert(data != NULL);
|
||||||
|
|
||||||
if (data->packets==0)
|
if (data->packets == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -226,12 +227,12 @@ sip_draw_hash_requests(gchar *key _U_ , sip_request_method_t *data, gchar * unus
|
||||||
/* Build string showing method and count */
|
/* Build string showing method and count */
|
||||||
g_snprintf(string_buff, sizeof(string_buff),
|
g_snprintf(string_buff, sizeof(string_buff),
|
||||||
" %-11s : %3d packets", data->response, data->packets);
|
" %-11s : %3d packets", data->response, data->packets);
|
||||||
if (data->widget==NULL)
|
if (data->widget == NULL)
|
||||||
{
|
{
|
||||||
/* Create new label */
|
/* Create new label */
|
||||||
data->widget=gtk_label_new(string_buff);
|
data->widget = gtk_label_new(string_buff);
|
||||||
gtk_misc_set_alignment(GTK_MISC(data->widget), 0.0f, 0.5f);
|
gtk_misc_set_alignment(GTK_MISC(data->widget), 0.0f, 0.5f);
|
||||||
gtk_box_pack_start(GTK_BOX(data->sp->request_box), data->widget,FALSE,FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(data->sp->request_box), data->widget, FALSE, FALSE, 0);
|
||||||
gtk_widget_show(data->widget);
|
gtk_widget_show(data->widget);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -247,22 +248,22 @@ sip_draw_hash_responses(gint * key _U_ , sip_response_code_t *data, gchar * unus
|
||||||
{
|
{
|
||||||
gchar string_buff[SUM_STR_MAX];
|
gchar string_buff[SUM_STR_MAX];
|
||||||
|
|
||||||
g_assert(data!=NULL);
|
g_assert(data != NULL);
|
||||||
|
|
||||||
if (data->packets==0)
|
if (data->packets == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create an entry in the relevant box of the window */
|
/* Create an entry in the relevant box of the window */
|
||||||
if (data->widget==NULL)
|
if (data->widget == NULL)
|
||||||
{
|
{
|
||||||
guint x;
|
guint x;
|
||||||
GtkWidget *tmp;
|
GtkWidget *tmp;
|
||||||
guint i = data->response_code;
|
guint i = data->response_code;
|
||||||
|
|
||||||
/* Out of valid range - ignore */
|
/* Out of valid range - ignore */
|
||||||
if ((i<100)||(i>=700))
|
if ((i < 100) || (i >= 700))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -297,12 +298,12 @@ sip_draw_hash_responses(gint * key _U_ , sip_response_code_t *data, gchar * unus
|
||||||
#if GTK_CHECK_VERSION(2,22,0)
|
#if GTK_CHECK_VERSION(2,22,0)
|
||||||
gtk_table_get_size(GTK_TABLE(data->table), &x, NULL);
|
gtk_table_get_size(GTK_TABLE(data->table), &x, NULL);
|
||||||
#else
|
#else
|
||||||
/* Work around GTK bug: Sealed in 2.14, accessor provided in 2.22 */
|
/* Work around GTK bug: Sealed in 2.14, accessor provided in 2.22 */
|
||||||
# if GTK_CHECK_VERSION (2, 14, 0) && defined(GSEAL_ENABLE)
|
# if GTK_CHECK_VERSION (2, 14, 0) && defined(GSEAL_ENABLE)
|
||||||
x = GTK_TABLE(data->table)->_g_sealed__nrows;
|
x = GTK_TABLE(data->table)->_g_sealed__nrows;
|
||||||
# else
|
# else
|
||||||
x = GTK_TABLE(data->table)->nrows;
|
x = GTK_TABLE(data->table)->nrows;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Create a new label with this response, e.g. "SIP 180 Ringing" */
|
/* Create a new label with this response, e.g. "SIP 180 Ringing" */
|
||||||
|
@ -317,7 +318,7 @@ sip_draw_hash_responses(gint * key _U_ , sip_response_code_t *data, gchar * unus
|
||||||
|
|
||||||
/* Show number of packets */
|
/* Show number of packets */
|
||||||
g_snprintf(string_buff, sizeof(string_buff), "%9d", data->packets);
|
g_snprintf(string_buff, sizeof(string_buff), "%9d", data->packets);
|
||||||
data->widget=gtk_label_new(string_buff);
|
data->widget = gtk_label_new(string_buff);
|
||||||
|
|
||||||
/* Show this widget in the right place */
|
/* Show this widget in the right place */
|
||||||
gtk_table_attach_defaults(GTK_TABLE(data->table), data->widget, 1, 2,x,x+1);
|
gtk_table_attach_defaults(GTK_TABLE(data->table), data->widget, 1, 2,x,x+1);
|
||||||
|
@ -330,7 +331,7 @@ sip_draw_hash_responses(gint * key _U_ , sip_response_code_t *data, gchar * unus
|
||||||
{
|
{
|
||||||
/* Just update the existing label string */
|
/* Just update the existing label string */
|
||||||
g_snprintf(string_buff, sizeof(string_buff), "%9d", data->packets);
|
g_snprintf(string_buff, sizeof(string_buff), "%9d", data->packets);
|
||||||
gtk_label_set_text(GTK_LABEL(data->widget), string_buff);
|
gtk_label_set_text(GTK_LABEL(data->widget), string_buff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,15 +362,15 @@ sipstat_reset(void *psp)
|
||||||
sipstat_t *sp = psp;
|
sipstat_t *sp = psp;
|
||||||
if (sp)
|
if (sp)
|
||||||
{
|
{
|
||||||
sp->packets = 0;
|
sp->packets = 0;
|
||||||
sp->resent_packets = 0;
|
sp->resent_packets = 0;
|
||||||
sp->average_setup_time = 0;
|
sp->average_setup_time = 0;
|
||||||
sp->max_setup_time = 0;
|
sp->max_setup_time = 0;
|
||||||
sp->max_setup_time = 0;
|
sp->max_setup_time = 0;
|
||||||
sp->no_of_completed_calls = 0;
|
sp->no_of_completed_calls = 0;
|
||||||
sp->total_setup_time = 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_responses, (GHFunc)sip_reset_hash_responses, NULL);
|
||||||
g_hash_table_foreach(sp->hash_requests, (GHFunc)sip_reset_hash_requests, NULL);
|
g_hash_table_foreach(sp->hash_requests, (GHFunc)sip_reset_hash_requests, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +378,7 @@ sipstat_reset(void *psp)
|
||||||
static int
|
static int
|
||||||
sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri)
|
sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri)
|
||||||
{
|
{
|
||||||
const sip_info_value_t *value=pri;
|
const sip_info_value_t *value = pri;
|
||||||
sipstat_t *sp = (sipstat_t *)psp;
|
sipstat_t *sp = (sipstat_t *)psp;
|
||||||
|
|
||||||
/* Total number of packets, including continuation packets */
|
/* Total number of packets, including continuation packets */
|
||||||
|
@ -389,27 +390,27 @@ sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const
|
||||||
sp->resent_packets++;
|
sp->resent_packets++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate average setup time */
|
/* Calculate average setup time */
|
||||||
if (value->setup_time){
|
if (value->setup_time){
|
||||||
sp->no_of_completed_calls++;
|
sp->no_of_completed_calls++;
|
||||||
/* Check if it's the first value */
|
/* Check if it's the first value */
|
||||||
if ( sp->total_setup_time == 0 ){
|
if ( sp->total_setup_time == 0 ){
|
||||||
sp->average_setup_time = value->setup_time;
|
sp->average_setup_time = value->setup_time;
|
||||||
sp->total_setup_time = value->setup_time;
|
sp->total_setup_time = value->setup_time;
|
||||||
sp->max_setup_time = value->setup_time;
|
sp->max_setup_time = value->setup_time;
|
||||||
sp->min_setup_time = value->setup_time;
|
sp->min_setup_time = value->setup_time;
|
||||||
}else{
|
}else{
|
||||||
sp->total_setup_time = sp->total_setup_time + value->setup_time;
|
sp->total_setup_time = sp->total_setup_time + value->setup_time;
|
||||||
if (sp->max_setup_time < value->setup_time){
|
if (sp->max_setup_time < value->setup_time){
|
||||||
sp->max_setup_time = value->setup_time;
|
sp->max_setup_time = value->setup_time;
|
||||||
}
|
}
|
||||||
if (sp->min_setup_time > value->setup_time){
|
if (sp->min_setup_time > value->setup_time){
|
||||||
sp->min_setup_time = value->setup_time;
|
sp->min_setup_time = value->setup_time;
|
||||||
}
|
}
|
||||||
/* Calculate average */
|
/* Calculate average */
|
||||||
sp->average_setup_time = (guint32)(sp->total_setup_time / sp->no_of_completed_calls);
|
sp->average_setup_time = (guint32)(sp->total_setup_time / sp->no_of_completed_calls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Looking at both requests and responses */
|
/* Looking at both requests and responses */
|
||||||
if (value->response_code != 0)
|
if (value->response_code != 0)
|
||||||
|
@ -421,37 +422,37 @@ sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const
|
||||||
/* Look up response code in hash table */
|
/* Look up response code in hash table */
|
||||||
*key = value->response_code;
|
*key = value->response_code;
|
||||||
sc = g_hash_table_lookup(sp->hash_responses, key);
|
sc = g_hash_table_lookup(sp->hash_responses, key);
|
||||||
if (sc==NULL)
|
if (sc == NULL)
|
||||||
{
|
{
|
||||||
/* Non-standard status code ; we classify it as others
|
/* Non-standard status code ; we classify it as others
|
||||||
* in the relevant category
|
* in the relevant category
|
||||||
* (Informational,Success,Redirection,Client Error,Server Error,Global Failure)
|
* (Informational,Success,Redirection,Client Error,Server Error,Global Failure)
|
||||||
*/
|
*/
|
||||||
int i = value->response_code;
|
int i = value->response_code;
|
||||||
if ((i<100) || (i>=700))
|
if ((i < 100) || (i >= 700))
|
||||||
{
|
{
|
||||||
/* Forget about crazy values */
|
/* Forget about crazy values */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (i<200)
|
else if (i<200)
|
||||||
{
|
{
|
||||||
*key=199; /* Hopefully, this status code will never be used */
|
*key = 199; /* Hopefully, this status code will never be used */
|
||||||
}
|
}
|
||||||
else if (i<300)
|
else if (i<300)
|
||||||
{
|
{
|
||||||
*key=299;
|
*key = 299;
|
||||||
}
|
}
|
||||||
else if (i<400)
|
else if (i<400)
|
||||||
{
|
{
|
||||||
*key=399;
|
*key = 399;
|
||||||
}
|
}
|
||||||
else if (i<500)
|
else if (i<500)
|
||||||
{
|
{
|
||||||
*key=499;
|
*key = 499;
|
||||||
}
|
}
|
||||||
else if (i<600)
|
else if (i < 600)
|
||||||
{
|
{
|
||||||
*key=599;
|
*key = 599;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -460,7 +461,7 @@ sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const
|
||||||
|
|
||||||
/* Now look up this fallback code to get its text description */
|
/* Now look up this fallback code to get its text description */
|
||||||
sc = g_hash_table_lookup(sp->hash_responses, key);
|
sc = g_hash_table_lookup(sp->hash_responses, key);
|
||||||
if (sc==NULL)
|
if (sc == NULL)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -477,11 +478,11 @@ sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const
|
||||||
if (sc == NULL)
|
if (sc == NULL)
|
||||||
{
|
{
|
||||||
/* First of this type. Create structure and initialise */
|
/* First of this type. Create structure and initialise */
|
||||||
sc=g_malloc(sizeof(sip_request_method_t));
|
sc = g_malloc(sizeof(sip_request_method_t));
|
||||||
sc->response = g_strdup(value->request_method);
|
sc->response = g_strdup(value->request_method);
|
||||||
sc->packets = 1;
|
sc->packets = 1;
|
||||||
sc->widget = NULL;
|
sc->widget = NULL;
|
||||||
sc->sp = sp;
|
sc->sp = sp;
|
||||||
/* Insert it into request table */
|
/* Insert it into request table */
|
||||||
g_hash_table_insert(sp->hash_requests, sc->response, sc);
|
g_hash_table_insert(sp->hash_requests, sc->response, sc);
|
||||||
}
|
}
|
||||||
|
@ -506,42 +507,43 @@ static void
|
||||||
sipstat_draw(void *psp)
|
sipstat_draw(void *psp)
|
||||||
{
|
{
|
||||||
gchar string_buff[SUM_STR_MAX];
|
gchar string_buff[SUM_STR_MAX];
|
||||||
sipstat_t *sp=psp;
|
sipstat_t *sp = psp;
|
||||||
|
|
||||||
/* Set summary label */
|
/* Set summary label */
|
||||||
g_snprintf(string_buff, sizeof(string_buff),
|
g_snprintf(string_buff, sizeof(string_buff),
|
||||||
"SIP stats (%d packets)", sp->packets);
|
"SIP stats (%d packets)", sp->packets);
|
||||||
gtk_label_set_text(GTK_LABEL(sp->packets_label), string_buff);
|
gtk_label_set_text(GTK_LABEL(sp->packets_label), string_buff);
|
||||||
|
|
||||||
/* Set resend count label */
|
/* Set resend count label */
|
||||||
g_snprintf(string_buff, sizeof(string_buff),
|
g_snprintf(string_buff, sizeof(string_buff),
|
||||||
"(%d resent packets)", sp->resent_packets);
|
"(%d resent packets)", sp->resent_packets);
|
||||||
gtk_label_set_text(GTK_LABEL(sp->resent_label), string_buff);
|
gtk_label_set_text(GTK_LABEL(sp->resent_label), string_buff);
|
||||||
|
|
||||||
/* Draw responses and requests from their tables */
|
/* Draw responses and requests from their tables */
|
||||||
g_hash_table_foreach(sp->hash_responses, (GHFunc)sip_draw_hash_responses, NULL);
|
g_hash_table_foreach(sp->hash_responses, (GHFunc)sip_draw_hash_responses, NULL);
|
||||||
g_hash_table_foreach(sp->hash_requests, (GHFunc)sip_draw_hash_requests, NULL);
|
g_hash_table_foreach(sp->hash_requests, (GHFunc)sip_draw_hash_requests, NULL);
|
||||||
|
|
||||||
/* Set resend count label */
|
/* Set resend count label */
|
||||||
g_snprintf(string_buff, sizeof(string_buff),
|
g_snprintf(string_buff, sizeof(string_buff),
|
||||||
"Average setup time %d ms\n Min %d ms\n Max %d ms", sp->average_setup_time, sp->min_setup_time, sp->max_setup_time);
|
"Average setup time %d ms\n Min %d ms\n Max %d ms",
|
||||||
gtk_label_set_text(GTK_LABEL(sp->average_setup_time_label), string_buff);
|
sp->average_setup_time, sp->min_setup_time, sp->max_setup_time);
|
||||||
|
gtk_label_set_text(GTK_LABEL(sp->average_setup_time_label), string_buff);
|
||||||
|
|
||||||
gtk_widget_show_all(sp->win);
|
gtk_widget_show_all(sp->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* since the gtk2 implementation of tap is multithreaded we must protect
|
/* Since the gtk2 implementation of tap is multithreaded we must protect
|
||||||
* remove_tap_listener() from modifying the list while draw_tap_listener()
|
* remove_tap_listener() from modifying the list while draw_tap_listener()
|
||||||
* is running. the other protected block is in main.c
|
* is running. The other protected block is in main.c
|
||||||
*
|
*
|
||||||
* there should not be any other critical regions in gtk2
|
* There should not be any other critical regions in gtk2
|
||||||
*/
|
*/
|
||||||
/* When window is destroyed, clean up */
|
/* When window is destroyed, clean up */
|
||||||
static void
|
static void
|
||||||
win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
||||||
{
|
{
|
||||||
sipstat_t *sp=(sipstat_t *)data;
|
sipstat_t *sp = (sipstat_t *)data;
|
||||||
|
|
||||||
protect_thread_critical_region();
|
protect_thread_critical_region();
|
||||||
remove_tap_listener(sp);
|
remove_tap_listener(sp);
|
||||||
|
@ -549,7 +551,7 @@ win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
||||||
|
|
||||||
g_hash_table_foreach(sp->hash_responses, (GHFunc)sip_free_hash, NULL);
|
g_hash_table_foreach(sp->hash_responses, (GHFunc)sip_free_hash, NULL);
|
||||||
g_hash_table_destroy(sp->hash_responses);
|
g_hash_table_destroy(sp->hash_responses);
|
||||||
g_hash_table_foreach(sp->hash_requests, (GHFunc)sip_free_hash, NULL);
|
g_hash_table_foreach(sp->hash_requests, (GHFunc)sip_free_hash, NULL);
|
||||||
g_hash_table_destroy(sp->hash_requests);
|
g_hash_table_destroy(sp->hash_requests);
|
||||||
g_free(sp->filter);
|
g_free(sp->filter);
|
||||||
g_free(sp);
|
g_free(sp);
|
||||||
|
@ -560,22 +562,22 @@ win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
||||||
static void
|
static void
|
||||||
gtk_sipstat_init(const char *optarg, void *userdata _U_)
|
gtk_sipstat_init(const char *optarg, void *userdata _U_)
|
||||||
{
|
{
|
||||||
sipstat_t *sp;
|
sipstat_t *sp;
|
||||||
const char *filter = NULL;
|
const char *filter;
|
||||||
GString *error_string;
|
GString *error_string;
|
||||||
char *title = NULL;
|
char *title;
|
||||||
GtkWidget *main_vb, *separator,
|
GtkWidget *main_vb, *separator,
|
||||||
*informational_fr, *success_fr, *redirection_fr,
|
*informational_fr, *success_fr, *redirection_fr,
|
||||||
*client_errors_fr, *server_errors_fr, *global_failures_fr,
|
*client_errors_fr, *server_errors_fr, *global_failures_fr,
|
||||||
*request_fr;
|
*request_fr;
|
||||||
GtkWidget *bt_close;
|
GtkWidget *bt_close;
|
||||||
GtkWidget *bbox;
|
GtkWidget *bbox;
|
||||||
|
|
||||||
|
|
||||||
if (strncmp (optarg, "sip,stat,", 9) == 0)
|
if (strncmp (optarg, "sip,stat,", 9) == 0)
|
||||||
{
|
{
|
||||||
/* Skip those characters from filter to display */
|
/* Skip those characters from filter to display */
|
||||||
filter=optarg + 9;
|
filter = optarg + 9;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -585,8 +587,8 @@ gtk_sipstat_init(const char *optarg, void *userdata _U_)
|
||||||
|
|
||||||
/* Create sip stats window structure */
|
/* Create sip stats window structure */
|
||||||
sp = g_malloc(sizeof(sipstat_t));
|
sp = g_malloc(sizeof(sipstat_t));
|
||||||
sp->win = dlg_window_new("sip-stat"); /* transient_for top_level */
|
sp->win = dlg_window_new("sip-stat"); /* transient_for top_level */
|
||||||
gtk_window_set_destroy_with_parent (GTK_WINDOW(sp->win), TRUE);
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(sp->win), TRUE);
|
||||||
|
|
||||||
/* Set title to include any filter given */
|
/* Set title to include any filter given */
|
||||||
if (filter)
|
if (filter)
|
||||||
|
@ -629,14 +631,14 @@ gtk_sipstat_init(const char *optarg, void *userdata _U_)
|
||||||
gtk_container_add(GTK_CONTAINER(informational_fr), sp->informational_table);
|
gtk_container_add(GTK_CONTAINER(informational_fr), sp->informational_table);
|
||||||
|
|
||||||
/* Success table and frame */
|
/* Success table and frame */
|
||||||
success_fr = gtk_frame_new ("Success SIP 2xx");
|
success_fr = gtk_frame_new("Success SIP 2xx");
|
||||||
gtk_box_pack_start(GTK_BOX(main_vb), success_fr, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(main_vb), success_fr, TRUE, TRUE, 0);
|
||||||
|
|
||||||
sp->success_table = gtk_table_new(0, 2, FALSE);
|
sp->success_table = gtk_table_new(0, 2, FALSE);
|
||||||
gtk_container_add(GTK_CONTAINER(success_fr), sp->success_table);
|
gtk_container_add(GTK_CONTAINER(success_fr), sp->success_table);
|
||||||
|
|
||||||
/* Redirection table and frame */
|
/* Redirection table and frame */
|
||||||
redirection_fr = gtk_frame_new ("Redirection SIP 3xx");
|
redirection_fr = gtk_frame_new("Redirection SIP 3xx");
|
||||||
gtk_box_pack_start(GTK_BOX(main_vb), redirection_fr, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(main_vb), redirection_fr, TRUE, TRUE, 0);
|
||||||
|
|
||||||
sp->redirection_table = gtk_table_new(0, 2, FALSE);
|
sp->redirection_table = gtk_table_new(0, 2, FALSE);
|
||||||
|
@ -677,8 +679,8 @@ gtk_sipstat_init(const char *optarg, void *userdata _U_)
|
||||||
gtk_container_add(GTK_CONTAINER(request_fr), sp->request_box);
|
gtk_container_add(GTK_CONTAINER(request_fr), sp->request_box);
|
||||||
|
|
||||||
sp->average_setup_time = 0;
|
sp->average_setup_time = 0;
|
||||||
sp->max_setup_time =0;
|
sp->max_setup_time =0;
|
||||||
sp->min_setup_time =0;
|
sp->min_setup_time =0;
|
||||||
sp->average_setup_time_label = gtk_label_new("(Not calculated)");
|
sp->average_setup_time_label = gtk_label_new("(Not calculated)");
|
||||||
gtk_box_pack_start(GTK_BOX(main_vb), sp->average_setup_time_label, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(main_vb), sp->average_setup_time_label, TRUE, TRUE, 0);
|
||||||
gtk_widget_show(sp->average_setup_time_label);
|
gtk_widget_show(sp->average_setup_time_label);
|
||||||
|
@ -702,7 +704,7 @@ gtk_sipstat_init(const char *optarg, void *userdata _U_)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Button row. */
|
/* Button row. */
|
||||||
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
|
||||||
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
@ -722,16 +724,16 @@ gtk_sipstat_init(const char *optarg, void *userdata _U_)
|
||||||
}
|
}
|
||||||
|
|
||||||
static tap_param sip_stat_params[] = {
|
static tap_param sip_stat_params[] = {
|
||||||
{ PARAM_FILTER, "Filter", NULL }
|
{ PARAM_FILTER, "Filter", NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static tap_param_dlg sip_stat_dlg = {
|
static tap_param_dlg sip_stat_dlg = {
|
||||||
"SIP Packet Counter",
|
"SIP Packet Counter",
|
||||||
"sip,stat",
|
"sip,stat",
|
||||||
gtk_sipstat_init,
|
gtk_sipstat_init,
|
||||||
-1,
|
-1,
|
||||||
G_N_ELEMENTS(sip_stat_params),
|
G_N_ELEMENTS(sip_stat_params),
|
||||||
sip_stat_params
|
sip_stat_params
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Register this tap listener and add menu item. */
|
/* Register this tap listener and add menu item. */
|
||||||
|
@ -743,6 +745,6 @@ register_tap_listener_gtksipstat(void)
|
||||||
|
|
||||||
void sipstat_cb(GtkAction *action, gpointer user_data _U_)
|
void sipstat_cb(GtkAction *action, gpointer user_data _U_)
|
||||||
{
|
{
|
||||||
tap_param_dlg_cb(action, &sip_stat_dlg);
|
tap_param_dlg_cb(action, &sip_stat_dlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue