Minor cleanup of the global namespace:

- Define some fcns and vars as static;
- Use less generic names for certain externs;
Also: Remove some usused #defines & cleanup some whitespace



git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@34488 f5534014-38df-0310-8fa8-9805f1628bb7
This commit is contained in:
wmeier 2010-10-12 16:05:19 +00:00
parent a7f84bd74c
commit c1a930b4a9
4 changed files with 221 additions and 224 deletions

View File

@ -40,6 +40,8 @@
# include <sys/types.h>
#endif
#include <glib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
@ -47,6 +49,7 @@
#include <gtk/gtk.h>
#include <epan/epan.h>
#include <epan/address.h>
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/strutil.h>
@ -62,19 +65,17 @@
#include <winsock2.h>
#endif
gint32 trigger=50; /* limit for triggering the burst alarm (in packets per second) */
gint32 bufferalarm = 10000; /* limit for triggernig the buffer alarm (in bytes) */
guint16 burstint = 100; /* burts interval in ms */
gint32 emptyspeed = 5000; /* outgoing speed for single stream (kbps)*/
gint32 cumulemptyspeed = 100000; /* outgoiong speed for all streams (kbps)*/
t_buffer **bufflist;
gint32 mcast_stream_trigger = 50; /* limit for triggering the burst alarm (in packets per second) */
gint32 mcast_stream_bufferalarm = 10000; /* limit for triggernig the buffer alarm (in bytes) */
guint16 mcast_stream_burstint = 100; /* burst interval in ms */
gint32 mcast_stream_emptyspeed = 5000; /* outgoing speed for single stream (kbps)*/
gint32 mcast_stream_cumulemptyspeed = 100000; /* outgoiong speed for all streams (kbps)*/
/* sliding window and buffer usage */
gint32 buffsize = (int)((double)MAX_SPEED * 100 / 1000) * 2;
guint16 comparetimes(struct timeval *t1, struct timeval *t2, guint16 burstint);
static void buffusagecalc(mcast_stream_info_t *strinfo, packet_info *pinfo, double emptyspeed);
static void slidingwindow(mcast_stream_info_t *strinfo, packet_info *pinfo);
static gint32 buffsize = (int)((double)MAX_SPEED * 100 / 1000) * 2;
static guint16 comparetimes(struct timeval *t1, struct timeval *t2, guint16 burstint_lcl);
static void buffusagecalc(mcast_stream_info_t *strinfo, packet_info *pinfo, double emptyspeed_lcl);
static void slidingwindow(mcast_stream_info_t *strinfo, packet_info *pinfo);
/****************************************************************************/
@ -85,7 +86,8 @@ static mcaststream_tapinfo_t the_tapinfo_struct =
/****************************************************************************/
/* GCompareFunc style comparison function for _mcast_stream_info */
static gint mcast_stream_info_cmp(gconstpointer aa, gconstpointer bb)
static gint
mcast_stream_info_cmp(gconstpointer aa, gconstpointer bb)
{
const struct _mcast_stream_info* a = aa;
const struct _mcast_stream_info* b = bb;
@ -107,7 +109,8 @@ static gint mcast_stream_info_cmp(gconstpointer aa, gconstpointer bb)
/****************************************************************************/
/* when there is a [re]reading of packet's */
void mcaststream_reset(mcaststream_tapinfo_t *tapinfo)
void
mcaststream_reset(mcaststream_tapinfo_t *tapinfo)
{
GList* list;
@ -136,14 +139,16 @@ void mcaststream_reset(mcaststream_tapinfo_t *tapinfo)
return;
}
static void mcaststream_reset_cb(void *arg)
static void
mcaststream_reset_cb(void *arg)
{
mcaststream_reset(arg);
}
/****************************************************************************/
/* redraw the output */
static void mcaststream_draw(void *arg _U_)
static void
mcaststream_draw(void *arg _U_)
{
/* XXX: see mcaststream_on_update in mcast_streams_dlg.c for comments
g_signal_emit_by_name(top_level, "signal_mcaststream_update");
@ -156,7 +161,8 @@ static void mcaststream_draw(void *arg _U_)
/****************************************************************************/
/* whenever a udp packet is seen by the tap listener */
static int mcaststream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *arg2 _U_)
static int
mcaststream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *arg2 _U_)
{
mcaststream_tapinfo_t *tapinfo = arg;
mcast_stream_info_t tmp_strinfo;
@ -282,10 +288,10 @@ static int mcaststream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt
/* sliding window and buffercalc for this group*/
slidingwindow(strinfo, pinfo);
buffusagecalc(strinfo, pinfo, emptyspeed*1000);
buffusagecalc(strinfo, pinfo, mcast_stream_emptyspeed*1000);
/* sliding window and buffercalc for all groups */
slidingwindow(tapinfo->allstreams, pinfo);
buffusagecalc(tapinfo->allstreams, pinfo, cumulemptyspeed*1000);
buffusagecalc(tapinfo->allstreams, pinfo, mcast_stream_cumulemptyspeed*1000);
/* end of sliding window */
return 1; /* refresh output */
@ -294,7 +300,8 @@ static int mcaststream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt
/****************************************************************************/
/* scan for Mcast streams */
void mcaststream_scan(void)
void
mcaststream_scan(void)
{
gboolean was_registered = the_tapinfo_struct.is_registered;
if (!the_tapinfo_struct.is_registered)
@ -308,7 +315,8 @@ void mcaststream_scan(void)
/****************************************************************************/
const mcaststream_tapinfo_t* mcaststream_get_info(void)
const mcaststream_tapinfo_t *
mcaststream_get_info(void)
{
return &the_tapinfo_struct;
}
@ -357,101 +365,105 @@ register_tap_listener_mcast_stream(void)
/* sliding window and buffer calculations */
/* compare two times */
guint16 comparetimes(struct timeval *t1, struct timeval *t2, guint16 burstint_lcl){
if(((t2->tv_sec - t1->tv_sec)*1000 + (t2->tv_usec - t1->tv_usec)/1000) > burstint_lcl){
return 1;
} else{
return 0;
}
static guint16
comparetimes(struct timeval *t1, struct timeval *t2, guint16 burstint_lcl)
{
if(((t2->tv_sec - t1->tv_sec)*1000 + (t2->tv_usec - t1->tv_usec)/1000) > burstint_lcl){
return 1;
} else{
return 0;
}
}
/* calculate buffer usage */
void buffusagecalc(mcast_stream_info_t *strinfo, packet_info *pinfo, double emptyspeed_lcl)
static void
buffusagecalc(mcast_stream_info_t *strinfo, packet_info *pinfo, double emptyspeed_lcl)
{
gint32 sec=0, usec=0, cur, prev;
struct timeval *buffer;
double timeelapsed;
gint32 sec=0, usec=0, cur, prev;
struct timeval *buffer;
double timeelapsed;
buffer = strinfo->element.buff;
cur = strinfo->element.last;
if(cur == 0){
cur = buffsize - 1;
prev = cur - 1;
} else if(cur == 1){
prev = buffsize - 1;
cur = 0;
} else{
cur=cur-1;
prev=cur-1;
}
buffer = strinfo->element.buff;
cur = strinfo->element.last;
if(cur == 0){
cur = buffsize - 1;
prev = cur - 1;
} else if(cur == 1){
prev = buffsize - 1;
cur = 0;
} else{
cur=cur-1;
prev=cur-1;
}
sec = buffer[cur].tv_sec - buffer[prev].tv_sec;
usec = buffer[cur].tv_usec - buffer[prev].tv_usec;
timeelapsed = (double)usec/1000000 + (double)sec;
sec = buffer[cur].tv_sec - buffer[prev].tv_sec;
usec = buffer[cur].tv_usec - buffer[prev].tv_usec;
timeelapsed = (double)usec/1000000 + (double)sec;
/* bytes added to buffer */
strinfo->element.buffusage+=pinfo->fd->pkt_len;
/* bytes added to buffer */
strinfo->element.buffusage+=pinfo->fd->pkt_len;
/* bytes cleared from buffer */
strinfo->element.buffusage-= (guint32) (timeelapsed * emptyspeed_lcl / 8);
/* bytes cleared from buffer */
strinfo->element.buffusage-= (guint32) (timeelapsed * emptyspeed_lcl / 8);
if(strinfo->element.buffusage < 0) strinfo->element.buffusage=0;
if(strinfo->element.buffusage > strinfo->element.topbuffusage)
strinfo->element.topbuffusage = strinfo->element.buffusage;
/* check for buffer losses */
if((strinfo->element.buffusage >= bufferalarm) && (strinfo->element.buffstatus == 0)){
strinfo->element.buffstatus = 1;
strinfo->element.numbuffalarms++;
} else if(strinfo->element.buffusage < bufferalarm){
strinfo->element.buffstatus = 0;
}
if(strinfo->element.buffusage < 0) strinfo->element.buffusage=0;
if(strinfo->element.buffusage > strinfo->element.topbuffusage)
strinfo->element.topbuffusage = strinfo->element.buffusage;
/* check for buffer losses */
if((strinfo->element.buffusage >= mcast_stream_bufferalarm) && (strinfo->element.buffstatus == 0)){
strinfo->element.buffstatus = 1;
strinfo->element.numbuffalarms++;
} else if(strinfo->element.buffusage < mcast_stream_bufferalarm){
strinfo->element.buffstatus = 0;
}
return;
return;
}
/* sliding window calculation */
void slidingwindow(mcast_stream_info_t *strinfo, packet_info *pinfo)
static void
slidingwindow(mcast_stream_info_t *strinfo, packet_info *pinfo)
{
struct timeval *buffer;
gint32 diff;
struct timeval *buffer;
gint32 diff;
buffer = strinfo->element.buff;
buffer = strinfo->element.buff;
diff = strinfo->element.last - strinfo->element.first;
if(diff < 0) diff+=buffsize;
diff = strinfo->element.last - strinfo->element.first;
if(diff < 0) diff+=buffsize;
/* check if buffer is full */
if(diff >= (buffsize - 2)){
fprintf(stderr, "Warning: capture buffer full\n");
strinfo->element.first++;
if(strinfo->element.first >= buffsize) strinfo->element.first = strinfo->element.first % buffsize;
}
/* check if buffer is full */
if(diff >= (buffsize - 2)){
fprintf(stderr, "Warning: capture buffer full\n");
strinfo->element.first++;
if(strinfo->element.first >= buffsize) strinfo->element.first = strinfo->element.first % buffsize;
}
/* burst count */
buffer[strinfo->element.last].tv_sec = (guint32) pinfo->fd->rel_ts.secs;
buffer[strinfo->element.last].tv_usec = pinfo->fd->rel_ts.nsecs/1000;
while(comparetimes((struct timeval *)&(buffer[strinfo->element.first]),
(struct timeval *)&(buffer[strinfo->element.last]), burstint)){
strinfo->element.first++;
if(strinfo->element.first >= buffsize) strinfo->element.first = strinfo->element.first % buffsize;
diff--;
}
strinfo->element.burstsize = diff;
if(strinfo->element.burstsize > strinfo->element.topburstsize) {
strinfo->element.topburstsize = strinfo->element.burstsize;
strinfo->element.maxbw = (float)(strinfo->element.topburstsize) * 1000 / burstint * pinfo->fd->pkt_len * 8 / 1000000;
}
/* burst count */
buffer[strinfo->element.last].tv_sec = (guint32) pinfo->fd->rel_ts.secs;
buffer[strinfo->element.last].tv_usec = pinfo->fd->rel_ts.nsecs/1000;
while(comparetimes((struct timeval *)&(buffer[strinfo->element.first]),
(struct timeval *)&(buffer[strinfo->element.last]), mcast_stream_burstint)){
strinfo->element.first++;
if(strinfo->element.first >= buffsize) strinfo->element.first = strinfo->element.first % buffsize;
diff--;
}
strinfo->element.burstsize = diff;
if(strinfo->element.burstsize > strinfo->element.topburstsize) {
strinfo->element.topburstsize = strinfo->element.burstsize;
strinfo->element.maxbw = (float)(strinfo->element.topburstsize) * 1000 / mcast_stream_burstint * pinfo->fd->pkt_len * 8 / 1000000;
}
strinfo->element.last++;
if(strinfo->element.last >= buffsize) strinfo->element.last = strinfo->element.last % buffsize;
/* trigger check */
if((strinfo->element.burstsize >= trigger) && (strinfo->element.burststatus == 0)){
strinfo->element.burststatus = 1;
strinfo->element.numbursts++;
} else if(strinfo->element.burstsize < trigger){
strinfo->element.burststatus = 0;
}
strinfo->element.last++;
if(strinfo->element.last >= buffsize) strinfo->element.last = strinfo->element.last % buffsize;
/* trigger check */
if((strinfo->element.burstsize >= mcast_stream_trigger) && (strinfo->element.burststatus == 0)){
strinfo->element.burststatus = 1;
strinfo->element.numbursts++;
} else if(strinfo->element.burstsize < mcast_stream_trigger){
strinfo->element.burststatus = 0;
}
strinfo->element.count++;
strinfo->element.count++;
}

View File

@ -32,40 +32,23 @@
#ifndef __MCAST_STREAM_H__
#define __MCAST_STREAM_H__
#include <glib.h>
#include <stdio.h>
#include <epan/address.h>
/**
* @todo - don't define stuff that potential name conflicts
*/
#define MCAST_INTERFACE 2
#define FILTER 3
#define TRIGGER 4
#define TIMER 5
#define REFRESHTIMER 6
#define EMPTYSPEED 7
#define BUFFERALARM 8
#define CUMULEMPTYSPEED 9
#define MAX_SPEED 200000
/* typedefs for sliding window and buffer size */
typedef struct buffer{
struct timeval *buff; /* packet times */
gint32 first; /* pointer to the first element */
gint32 last; /* pointer to the last element */
gint32 burstsize; /* current burst */
gint32 topburstsize; /* maximum burst in the refresh interval*/
gint32 count; /* packet counter */
gint32 burststatus; /* burst status */
gint32 numbursts; /* number of bursts */
gint32 buffusage; /* buffer usage */
gint32 buffstatus; /* buffer status */
gint32 numbuffalarms; /* number of alarms triggered by buffer underruns */
gint32 topbuffusage; /* top buffer usage in refresh interval */
float maxbw; /* maximum bandwidth usage */
struct timeval *buff; /* packet times */
gint32 first; /* pointer to the first element */
gint32 last; /* pointer to the last element */
gint32 burstsize; /* current burst */
gint32 topburstsize; /* maximum burst in the refresh interval*/
gint32 count; /* packet counter */
gint32 burststatus; /* burst status */
gint32 numbursts; /* number of bursts */
gint32 buffusage; /* buffer usage */
gint32 buffstatus; /* buffer status */
gint32 numbuffalarms; /* number of alarms triggered by buffer underruns */
gint32 topbuffusage; /* top buffer usage in refresh interval */
float maxbw; /* maximum bandwidth usage */
} t_buffer;
@ -89,7 +72,7 @@ typedef struct _mcast_stream_info {
guint32 stop_rel_sec; /* stop stream rel seconds */
guint32 stop_rel_usec; /* stop stream rel microseconds */
guint16 vlan_id;
/*for the sliding window */
t_buffer element;
@ -108,6 +91,13 @@ typedef struct _mcaststream_tapinfo {
gboolean is_registered; /* if the tap listener is currently registered or not */
} mcaststream_tapinfo_t;
extern gint32 mcast_stream_trigger;
extern gint32 mcast_stream_bufferalarm;
extern guint16 mcast_stream_burstint;
extern gint32 mcast_stream_emptyspeed;
extern gint32 mcast_stream_cumulemptyspeed;
/****************************************************************************/
/* INTERFACE */

View File

@ -61,12 +61,6 @@
#define E_MCAST_ENTRY_4 "stream_speed"
#define E_MCAST_ENTRY_5 "total_speed"
extern guint16 burstint;
extern guint32 trigger;
extern guint32 bufferalarm;
extern gint32 emptyspeed;
extern gint32 cumulemptyspeed;
static const gchar FWD_LABEL_TEXT[] = "Select a stream with left mouse button";
static const gchar PAR_LABEL_TEXT[] = "\nBurst int: ms Burst alarm: pps Buffer alarm: KB Stream empty speed: Mbps Total empty speed: Mbps\n";
@ -89,20 +83,20 @@ static guint32 streams_nb = 0; /* number of displayed streams */
enum
{
MC_COL_SRC_ADDR,
MC_COL_SRC_PORT,
MC_COL_DST_ADDR,
MC_COL_DST_PORT,
MC_COL_PACKETS,
MC_COL_PPS,
MC_COL_AVG_BW,
MC_COL_MAX_BW,
MC_COL_MAX_BURST,
MC_COL_BURST_ALARM,
MC_COL_MAX_BUFFER,
MC_COL_BUFFER_ALARM,
MC_COL_DATA,
NUM_COLS /* The number of columns */
MC_COL_SRC_ADDR,
MC_COL_SRC_PORT,
MC_COL_DST_ADDR,
MC_COL_DST_PORT,
MC_COL_PACKETS,
MC_COL_PPS,
MC_COL_AVG_BW,
MC_COL_MAX_BW,
MC_COL_MAX_BURST,
MC_COL_BURST_ALARM,
MC_COL_MAX_BUFFER,
MC_COL_BUFFER_ALARM,
MC_COL_DATA,
NUM_COLS /* The number of columns */
};
/****************************************************************************/
@ -201,7 +195,8 @@ mcaststream_on_select_row(GtkTreeSelection *selection, gpointer data _U_)
/****************************************************************************/
/* INTERFACE */
/****************************************************************************/
static void mcast_params_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
static void
mcast_params_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
{
/* Note that we no longer have a mcast params dialog box. */
mcast_params_dlg = NULL;
@ -223,7 +218,7 @@ mcast_params_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The burst interval should be between 1 and 1000 ms.");
return;
}
burstint = fnumber;
mcast_stream_burstint = fnumber;
fnumber_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_MCAST_ENTRY_2);
fnumber_text = gtk_entry_get_text(GTK_ENTRY(fnumber_te));
@ -232,7 +227,7 @@ mcast_params_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The burst alarm threshold you entered isn't valid.");
return;
}
trigger = fnumber;
mcast_stream_trigger = fnumber;
fnumber_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_MCAST_ENTRY_3);
fnumber_text = gtk_entry_get_text(GTK_ENTRY(fnumber_te));
@ -241,7 +236,7 @@ mcast_params_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The buffer alarm threshold you entered isn't valid.");
return;
}
bufferalarm = fnumber;
mcast_stream_bufferalarm = fnumber;
fnumber_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_MCAST_ENTRY_4);
fnumber_text = gtk_entry_get_text(GTK_ENTRY(fnumber_te));
@ -250,7 +245,7 @@ mcast_params_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The stream empty speed should be between 1 and 10000000");
return;
}
emptyspeed = fnumber;
mcast_stream_emptyspeed = fnumber;
fnumber_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_MCAST_ENTRY_5);
fnumber_text = gtk_entry_get_text(GTK_ENTRY(fnumber_te));
@ -259,7 +254,7 @@ mcast_params_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The total empty speed should be between 1 and 10000000");
return;
}
cumulemptyspeed = fnumber;
mcast_stream_cumulemptyspeed = fnumber;
window_destroy(GTK_WIDGET(parent_w));
@ -304,31 +299,31 @@ mcast_on_params(GtkButton *button _U_, gpointer data _U_)
label = gtk_label_new(" Burst measurement interval (ms) ");
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
entry1 = gtk_entry_new();
g_snprintf(label_text, sizeof(label_text), "%u", burstint);
g_snprintf(label_text, sizeof(label_text), "%u", mcast_stream_burstint);
gtk_entry_set_text(GTK_ENTRY(entry1), label_text);
gtk_table_attach_defaults(GTK_TABLE(table), entry1, 1, 2, 0, 1);
label = gtk_label_new(" Burst alarm threshold (packets) ");
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
entry2 = gtk_entry_new();
g_snprintf(label_text, sizeof(label_text), "%u", trigger);
g_snprintf(label_text, sizeof(label_text), "%u", mcast_stream_trigger);
gtk_entry_set_text(GTK_ENTRY(entry2), label_text);
gtk_table_attach_defaults(GTK_TABLE(table), entry2, 1, 2, 1, 2);
label = gtk_label_new(" Buffer alarm threshold (bytes) ");
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
entry3 = gtk_entry_new();
g_snprintf(label_text, sizeof(label_text), "%u", bufferalarm);
g_snprintf(label_text, sizeof(label_text), "%u", mcast_stream_bufferalarm);
gtk_entry_set_text(GTK_ENTRY(entry3), label_text);
gtk_table_attach_defaults(GTK_TABLE(table), entry3, 1, 2, 2, 3);
label = gtk_label_new(" Stream empty speed (kbit/s) ");
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
entry4 = gtk_entry_new();
g_snprintf(label_text, sizeof(label_text), "%u", emptyspeed);
g_snprintf(label_text, sizeof(label_text), "%u", mcast_stream_emptyspeed);
gtk_entry_set_text(GTK_ENTRY(entry4), label_text);
gtk_table_attach_defaults(GTK_TABLE(table), entry4, 1, 2, 3, 4);
label = gtk_label_new(" Total empty speed (kbit/s) ");
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 4, 5);
entry5 = gtk_entry_new();
g_snprintf(label_text, sizeof(label_text), "%u", cumulemptyspeed);
g_snprintf(label_text, sizeof(label_text), "%u", mcast_stream_cumulemptyspeed);
gtk_entry_set_text(GTK_ENTRY(entry5), label_text);
gtk_table_attach_defaults(GTK_TABLE(table), entry5, 1, 2, 4, 5);
@ -385,7 +380,7 @@ add_to_list_store(mcast_stream_info_t* strinfo)
data[5] = g_strdup_printf("%u /s", strinfo->apackets);
data[6] = g_strdup_printf("%2.1f Mbps", strinfo->average_bw);
data[7] = g_strdup_printf("%2.1f Mbps", strinfo->element.maxbw);
data[8] = g_strdup_printf("%u / %dms", strinfo->element.topburstsize, burstint);
data[8] = g_strdup_printf("%u / %dms", strinfo->element.topburstsize, mcast_stream_burstint);
data[9] = g_strdup_printf("%u", strinfo->element.numbursts);
data[10] = g_strdup_printf("%.1f KB", (float)strinfo->element.topbuffusage/1000);
data[11] = g_strdup_printf("%u", strinfo->element.numbuffalarms);
@ -421,12 +416,12 @@ add_to_list_store(mcast_stream_info_t* strinfo)
"Detected %d Multicast streams, Average Bw: %.1f Mbps Max Bw: %.1f Mbps Max burst: %d / %dms Max buffer: %.1f KB",
++streams_nb,
mcaststream_get_info()->allstreams->average_bw, mcaststream_get_info()->allstreams->element.maxbw,
mcaststream_get_info()->allstreams->element.topburstsize, burstint,
mcaststream_get_info()->allstreams->element.topburstsize, mcast_stream_burstint,
(float)(mcaststream_get_info()->allstreams->element.topbuffusage)/1000);
gtk_label_set_text(GTK_LABEL(top_label), label_text);
g_snprintf(label_text, sizeof(label_text), "\nBurst int: %u ms Burst alarm: %u pps Buffer alarm: %u Bytes Stream empty speed: %u Kbps Total empty speed: %u Kbps\n",
burstint, trigger, bufferalarm, emptyspeed, cumulemptyspeed);
mcast_stream_burstint, mcast_stream_trigger, mcast_stream_bufferalarm, mcast_stream_emptyspeed, mcast_stream_cumulemptyspeed);
gtk_label_set_text(GTK_LABEL(label_par), label_text);
}
@ -644,84 +639,84 @@ create_list_view(void)
static void
mcaststream_dlg_create(void)
{
GtkWidget *mcaststream_dlg_w;
GtkWidget *main_vb;
GtkWidget *scrolledwindow;
GtkWidget *hbuttonbox;
/*GtkWidget *bt_unselect;*/
GtkWidget *bt_params;
GtkWidget *bt_close;
GtkTooltips *tooltips = gtk_tooltips_new();
GtkWidget *mcaststream_dlg_w;
GtkWidget *main_vb;
GtkWidget *scrolledwindow;
GtkWidget *hbuttonbox;
/*GtkWidget *bt_unselect;*/
GtkWidget *bt_params;
GtkWidget *bt_close;
GtkTooltips *tooltips = gtk_tooltips_new();
const gchar *title_name_ptr;
gchar *win_name;
const gchar *title_name_ptr;
gchar *win_name;
title_name_ptr = cf_get_display_name(&cfile);
win_name = g_strdup_printf("%s - UDP Multicast Streams", title_name_ptr);
mcaststream_dlg_w = dlg_window_new(win_name);
title_name_ptr = cf_get_display_name(&cfile);
win_name = g_strdup_printf("%s - UDP Multicast Streams", title_name_ptr);
mcaststream_dlg_w = dlg_window_new(win_name);
gtk_window_set_default_size(GTK_WINDOW(mcaststream_dlg_w), 620, 400);
gtk_window_set_default_size(GTK_WINDOW(mcaststream_dlg_w), 620, 400);
main_vb = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(mcaststream_dlg_w), main_vb);
gtk_container_set_border_width (GTK_CONTAINER (main_vb), 12);
main_vb = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(mcaststream_dlg_w), main_vb);
gtk_container_set_border_width (GTK_CONTAINER (main_vb), 12);
top_label = gtk_label_new ("Detected 0 Multicast streams");
gtk_box_pack_start (GTK_BOX (main_vb), top_label, FALSE, FALSE, 8);
top_label = gtk_label_new ("Detected 0 Multicast streams");
gtk_box_pack_start (GTK_BOX (main_vb), top_label, FALSE, FALSE, 8);
scrolledwindow = scrolled_window_new (NULL, NULL);
gtk_box_pack_start (GTK_BOX (main_vb), scrolledwindow, TRUE, TRUE, 0);
scrolledwindow = scrolled_window_new (NULL, NULL);
gtk_box_pack_start (GTK_BOX (main_vb), scrolledwindow, TRUE, TRUE, 0);
create_list_view();
gtk_container_add(GTK_CONTAINER(scrolledwindow), list_w);
create_list_view();
gtk_container_add(GTK_CONTAINER(scrolledwindow), list_w);
gtk_widget_show(mcaststream_dlg_w);
gtk_widget_show(mcaststream_dlg_w);
label_fwd = gtk_label_new (FWD_LABEL_TEXT);
gtk_box_pack_start (GTK_BOX (main_vb), label_fwd, FALSE, FALSE, 0);
label_fwd = gtk_label_new (FWD_LABEL_TEXT);
gtk_box_pack_start (GTK_BOX (main_vb), label_fwd, FALSE, FALSE, 0);
label_par = gtk_label_new (PAR_LABEL_TEXT);
gtk_box_pack_start (GTK_BOX (main_vb), label_par, FALSE, FALSE, 0);
label_par = gtk_label_new (PAR_LABEL_TEXT);
gtk_box_pack_start (GTK_BOX (main_vb), label_par, FALSE, FALSE, 0);
/* button row */
hbuttonbox = gtk_hbutton_box_new ();
gtk_box_pack_start (GTK_BOX (main_vb), hbuttonbox, FALSE, FALSE, 0);
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_END);
gtk_box_set_spacing (GTK_BOX (hbuttonbox), 0);
/* button row */
hbuttonbox = gtk_hbutton_box_new ();
gtk_box_pack_start (GTK_BOX (main_vb), hbuttonbox, FALSE, FALSE, 0);
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_END);
gtk_box_set_spacing (GTK_BOX (hbuttonbox), 0);
/*bt_unselect = gtk_button_new_with_label ("Unselect");
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_unselect);
gtk_tooltips_set_tip (tooltips, bt_unselect, "Undo stream selection", NULL);*/
/*bt_unselect = gtk_button_new_with_label ("Unselect");
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_unselect);
gtk_tooltips_set_tip (tooltips, bt_unselect, "Undo stream selection", NULL);*/
bt_params = gtk_button_new_with_label ("Set parameters");
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_params);
gtk_tooltips_set_tip (tooltips, bt_params, "Set buffer, limit and speed parameters", NULL);
bt_params = gtk_button_new_with_label ("Set parameters");
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_params);
gtk_tooltips_set_tip (tooltips, bt_params, "Set buffer, limit and speed parameters", NULL);
bt_filter = gtk_button_new_with_label ("Prepare Filter");
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_filter);
gtk_tooltips_set_tip (tooltips, bt_filter, "Prepare a display filter of the selected stream", NULL);
bt_filter = gtk_button_new_with_label ("Prepare Filter");
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_filter);
gtk_tooltips_set_tip (tooltips, bt_filter, "Prepare a display filter of the selected stream", NULL);
bt_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_close);
gtk_tooltips_set_tip (tooltips, bt_close, "Close this dialog", NULL);
GTK_WIDGET_SET_FLAGS(bt_close, GTK_CAN_DEFAULT);
bt_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_close);
gtk_tooltips_set_tip (tooltips, bt_close, "Close this dialog", NULL);
GTK_WIDGET_SET_FLAGS(bt_close, GTK_CAN_DEFAULT);
/*g_signal_connect(bt_unselect, "clicked", G_CALLBACK(mcaststream_on_unselect), NULL);*/
g_signal_connect(bt_params, "clicked", G_CALLBACK(mcast_on_params), NULL);
g_signal_connect(bt_filter, "clicked", G_CALLBACK(mcaststream_on_filter), NULL);
window_set_cancel_button(mcaststream_dlg_w, bt_close, window_cancel_button_cb);
/*g_signal_connect(bt_unselect, "clicked", G_CALLBACK(mcaststream_on_unselect), NULL);*/
g_signal_connect(bt_params, "clicked", G_CALLBACK(mcast_on_params), NULL);
g_signal_connect(bt_filter, "clicked", G_CALLBACK(mcaststream_on_filter), NULL);
window_set_cancel_button(mcaststream_dlg_w, bt_close, window_cancel_button_cb);
g_signal_connect(mcaststream_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
g_signal_connect(mcaststream_dlg_w, "destroy", G_CALLBACK(mcaststream_on_destroy), NULL);
g_signal_connect(mcaststream_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
g_signal_connect(mcaststream_dlg_w, "destroy", G_CALLBACK(mcaststream_on_destroy), NULL);
gtk_widget_show_all(mcaststream_dlg_w);
window_present(mcaststream_dlg_w);
gtk_widget_show_all(mcaststream_dlg_w);
window_present(mcaststream_dlg_w);
mcaststream_on_unselect(NULL, NULL);
mcaststream_on_unselect(NULL, NULL);
mcast_stream_dlg = mcaststream_dlg_w;
mcast_stream_dlg = mcaststream_dlg_w;
g_free(win_name);
g_free(win_name);
}
@ -733,7 +728,8 @@ mcaststream_dlg_create(void)
/****************************************************************************/
/* update the contents of the dialog box clist */
/* list: pointer to list of mcast_stream_info_t* */
void mcaststream_dlg_update(GList *list)
void
mcaststream_dlg_update(GList *list)
{
if (mcast_stream_dlg != NULL) {
gtk_list_store_clear(list_store);
@ -756,7 +752,8 @@ void mcaststream_dlg_update(GList *list)
/****************************************************************************/
/* update the contents of the dialog box clist */
/* list: pointer to list of mcast_stream_info_t* */
void mcaststream_dlg_show(GList *list)
void
mcaststream_dlg_show(GList *list)
{
if (mcast_stream_dlg != NULL) {
/* There's already a dialog box; reactivate it. */
@ -776,7 +773,8 @@ void mcaststream_dlg_show(GList *list)
/****************************************************************************/
/* entry point when called via the GTK menu */
static void mcaststream_launch(GtkWidget *w _U_, gpointer data _U_)
static void
mcaststream_launch(GtkWidget *w _U_, gpointer data _U_)
{
/* Register the tap listener */
register_tap_listener_mcast_stream();

View File

@ -32,9 +32,6 @@
#ifndef __MCAST_STREAM_DLG_H__
#define __MCAST_STREAM_DLG_H__
#include <gtk/gtk.h>
/** @file
* @ingroup dialog_group
* "Mcast Stream Analysis" dialog box.