diff options
Diffstat (limited to 'ui/gtk')
-rw-r--r-- | ui/gtk/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ui/gtk/Makefile.common | 4 | ||||
-rw-r--r-- | ui/gtk/mcast_stream.c | 474 | ||||
-rw-r--r-- | ui/gtk/mcast_stream.h | 147 | ||||
-rw-r--r-- | ui/gtk/mcast_stream_dlg.c | 52 | ||||
-rw-r--r-- | ui/gtk/mcast_stream_dlg.h | 10 |
6 files changed, 48 insertions, 640 deletions
diff --git a/ui/gtk/CMakeLists.txt b/ui/gtk/CMakeLists.txt index ea3b6ae4dd..3a7e95ec35 100644 --- a/ui/gtk/CMakeLists.txt +++ b/ui/gtk/CMakeLists.txt @@ -75,7 +75,6 @@ set(WIRESHARK_GTK_SRC main_toolbar.c main_welcome.c manual_addr_resolv.c - mcast_stream.c packet_history.c packet_list_store.c packet_list.c diff --git a/ui/gtk/Makefile.common b/ui/gtk/Makefile.common index 5de6296d16..a35737ae16 100644 --- a/ui/gtk/Makefile.common +++ b/ui/gtk/Makefile.common @@ -96,7 +96,6 @@ WIRESHARK_GTK_SRC = \ main_titlebar.c \ main_toolbar.c \ main_welcome.c \ - mcast_stream.c \ packet_history.c \ packet_list_store.c \ packet_list.c \ @@ -271,8 +270,7 @@ noinst_HEADERS = \ main_toolbar_private.h \ main_welcome.h \ manual_addr_resolv.h \ - mcast_stream.h \ - mcast_stream_dlg.h \ + mcast_stream_dlg.h \ mtp3_stat.h \ network_icons.h \ old-gtk-compat.h \ diff --git a/ui/gtk/mcast_stream.c b/ui/gtk/mcast_stream.c deleted file mode 100644 index a3a3321706..0000000000 --- a/ui/gtk/mcast_stream.c +++ /dev/null @@ -1,474 +0,0 @@ -/* mcast_stream.c - * - * Copyright 2006, Iskratel , Slovenia - * By Jakob Bratkovic <j.bratkovic@iskratel.si> and - * Miha Jemec <m.jemec@iskratel.si> - * - * based on rtp_stream.c - * Copyright 2003, Alcatel Business Systems - * By Lars Ruoff <lars.ruoff@gmx.net> - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif - -#include <glib.h> - -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <string.h> - -#include <gtk/gtk.h> - -#include <epan/epan.h> -#include <epan/address.h> -#include <epan/packet.h> -#include <epan/tap.h> -#include <epan/to_str.h> - -#include "ui/alert_box.h" -#include "ui/simple_dialog.h" - -#include "ui/gtk/mcast_stream.h" -#include "ui/gtk/mcast_stream_dlg.h" -#include "ui/gtk/main.h" -#include "ui/gtk/stock_icons.h" - -#ifdef HAVE_WINSOCK2_H -#include <winsock2.h> -#endif - -gint32 mcast_stream_trigger = 50; /* limit for triggering the burst alarm (in packets per second) */ -gint32 mcast_stream_bufferalarm = 10000; /* limit for triggering 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 */ -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); - - -/****************************************************************************/ -/* the one and only global mcaststream_tapinfo_t structure */ -static mcaststream_tapinfo_t the_tapinfo_struct = - {0, NULL, 0, NULL, 0, FALSE}; - - -/****************************************************************************/ -/* GCompareFunc style comparison function for _mcast_stream_info */ -static gint -mcast_stream_info_cmp(gconstpointer aa, gconstpointer bb) -{ - const struct _mcast_stream_info* a = (const struct _mcast_stream_info *)aa; - const struct _mcast_stream_info* b = (const struct _mcast_stream_info *)bb; - - if (a==b) - return 0; - if (a==NULL || b==NULL) - return 1; - if (ADDRESSES_EQUAL(&(a->src_addr), &(b->src_addr)) - && (a->src_port == b->src_port) - && ADDRESSES_EQUAL(&(a->dest_addr), &(b->dest_addr)) - && (a->dest_port == b->dest_port)) - return 0; - else - return 1; - -} - - -/****************************************************************************/ -/* when there is a [re]reading of packet's */ -void -mcaststream_reset(mcaststream_tapinfo_t *tapinfo) -{ - GList* list; - - /* free the data items first */ - list = g_list_first(tapinfo->strinfo_list); - while (list) - { - /* XYZ I don't know how to clean this */ - /*g_free(list->element.buff); */ - g_free(list->data); - list = g_list_next(list); - } - g_list_free(tapinfo->strinfo_list); - tapinfo->strinfo_list = NULL; - - /* XYZ and why does the line below causes a crach? */ - /*g_free(tapinfo->allstreams->element.buff);*/ - g_free(tapinfo->allstreams); - tapinfo->allstreams = NULL; - - tapinfo->nstreams = 0; - tapinfo->npackets = 0; - - ++(tapinfo->launch_count); - - return; -} - -static void -mcaststream_reset_cb(void *arg) -{ - mcaststream_reset((mcaststream_tapinfo_t *)arg); -} - -/****************************************************************************/ -/* redraw the output */ -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"); -*/ - mcaststream_dlg_update(the_tapinfo_struct.strinfo_list); - return; -} - - - -/****************************************************************************/ -/* 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_) -{ - mcaststream_tapinfo_t *tapinfo = (mcaststream_tapinfo_t *)arg; - mcast_stream_info_t tmp_strinfo; - mcast_stream_info_t *strinfo = NULL; - GList* list; - float deltatime; - - /* gather infos on the stream this packet is part of */ - COPY_ADDRESS(&(tmp_strinfo.src_addr), &(pinfo->src)); - tmp_strinfo.src_port = pinfo->srcport; - COPY_ADDRESS(&(tmp_strinfo.dest_addr), &(pinfo->dst)); - tmp_strinfo.dest_port = pinfo->destport; - - /* first we ignore non multicast packets; we filter out only those ethernet packets - * which start with the 01:00:5E multicast address (for IPv4) and 33:33 multicast - * address (for IPv6). - */ - if ((pinfo->dl_dst.type != AT_ETHER) || - ((g_ascii_strncasecmp("01005E", bytes_to_str(pinfo->pool, (const guint8 *)pinfo->dl_dst.data, pinfo->dl_dst.len), 6) != 0) && - (g_ascii_strncasecmp("3333", bytes_to_str(pinfo->pool, (const guint8 *)pinfo->dl_dst.data, pinfo->dl_dst.len), 4) != 0)) ) - return 0; - - /* check whether we already have a stream with these parameters in the list */ - list = g_list_first(tapinfo->strinfo_list); - while (list) - { - if (mcast_stream_info_cmp(&tmp_strinfo, (mcast_stream_info_t*)(list->data))==0) - { - strinfo = (mcast_stream_info_t*)(list->data); /*found!*/ - break; - } - list = g_list_next(list); - } - - /* not in the list? then create a new entry */ - if (!strinfo) { - /*printf("nov sip %s sp %d dip %s dp %d\n", address_to_display(NULL, &(pinfo->src)), - pinfo->srcport, address_to_display(NULL, &(pinfo->dst)), pinfo->destport);*/ - tmp_strinfo.npackets = 0; - tmp_strinfo.apackets = 0; - tmp_strinfo.first_frame_num = pinfo->fd->num; - tmp_strinfo.start_sec = (guint32) pinfo->fd->abs_ts.secs; - tmp_strinfo.start_usec = pinfo->fd->abs_ts.nsecs/1000; - tmp_strinfo.start_rel_sec = (guint32) pinfo->rel_ts.secs; - tmp_strinfo.start_rel_usec = pinfo->rel_ts.nsecs/1000; - tmp_strinfo.vlan_id = 0; - - /* reset Mcast stats */ - tmp_strinfo.average_bw = 0; - tmp_strinfo.total_bytes = 0; - - /* reset slidingwindow and buffer parameters */ - tmp_strinfo.element.buff = (struct timeval *)g_malloc(buffsize * sizeof(struct timeval)); - tmp_strinfo.element.first=0; - tmp_strinfo.element.last=0; - tmp_strinfo.element.burstsize=1; - tmp_strinfo.element.topburstsize=1; - tmp_strinfo.element.numbursts=0; - tmp_strinfo.element.burststatus=0; - tmp_strinfo.element.count=1; - tmp_strinfo.element.buffusage=pinfo->fd->pkt_len; - tmp_strinfo.element.topbuffusage=pinfo->fd->pkt_len; - tmp_strinfo.element.numbuffalarms=0; - tmp_strinfo.element.buffstatus=0; - tmp_strinfo.element.maxbw=0; - - strinfo = (mcast_stream_info_t *)g_malloc(sizeof(mcast_stream_info_t)); - *strinfo = tmp_strinfo; /* memberwise copy of struct */ - tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo); - strinfo->element.buff = (struct timeval *)g_malloc(buffsize * sizeof(struct timeval)); - - /* set time with the first packet */ - if (tapinfo->npackets == 0) { - tapinfo->allstreams = (mcast_stream_info_t *)g_malloc(sizeof(mcast_stream_info_t)); - tapinfo->allstreams->element.buff = - (struct timeval *)g_malloc(buffsize * sizeof(struct timeval)); - tapinfo->allstreams->start_rel_sec = (guint32) pinfo->rel_ts.secs; - tapinfo->allstreams->start_rel_usec = pinfo->rel_ts.nsecs/1000; - tapinfo->allstreams->total_bytes = 0; - tapinfo->allstreams->element.first=0; - tapinfo->allstreams->element.last=0; - tapinfo->allstreams->element.burstsize=1; - tapinfo->allstreams->element.topburstsize=1; - tapinfo->allstreams->element.numbursts=0; - tapinfo->allstreams->element.burststatus=0; - tapinfo->allstreams->element.count=1; - tapinfo->allstreams->element.buffusage=pinfo->fd->pkt_len; - tapinfo->allstreams->element.topbuffusage=pinfo->fd->pkt_len; - tapinfo->allstreams->element.numbuffalarms=0; - tapinfo->allstreams->element.buffstatus=0; - tapinfo->allstreams->element.maxbw=0; - } - } - - /* time between first and last packet in the group */ - strinfo->stop_rel_sec = (guint32) pinfo->rel_ts.secs; - strinfo->stop_rel_usec = pinfo->rel_ts.nsecs/1000; - deltatime = ((float)((strinfo->stop_rel_sec * 1000000 + strinfo->stop_rel_usec) - - (strinfo->start_rel_sec*1000000 + strinfo->start_rel_usec)))/1000000; - - /* calculate average bandwidth for this stream */ - strinfo->total_bytes = strinfo->total_bytes + pinfo->fd->pkt_len; - if (deltatime > 0) - strinfo->average_bw = (((float)(strinfo->total_bytes*8) / deltatime) / 1000000); - - /* increment the packets counter for this stream and calculate average pps */ - ++(strinfo->npackets); - strinfo->apackets = (guint32) (strinfo->npackets / deltatime); - - /* time between first and last packet in any group */ - tapinfo->allstreams->stop_rel_sec = (guint32) pinfo->rel_ts.secs; - tapinfo->allstreams->stop_rel_usec = pinfo->rel_ts.nsecs/1000; - deltatime = ((float)((tapinfo->allstreams->stop_rel_sec * 1000000 + tapinfo->allstreams->stop_rel_usec) - - (tapinfo->allstreams->start_rel_sec*1000000 + tapinfo->allstreams->start_rel_usec)))/1000000; - - /* increment the packets counter of all streams */ - ++(tapinfo->npackets); - - /* calculate average bandwidth for all streams */ - tapinfo->allstreams->total_bytes = tapinfo->allstreams->total_bytes + pinfo->fd->pkt_len; - if (deltatime > 0) - tapinfo->allstreams->average_bw = (((float)(tapinfo->allstreams->total_bytes *8) / deltatime) / 1000000); - - /* sliding window and buffercalc for this group*/ - slidingwindow(strinfo, pinfo); - buffusagecalc(strinfo, pinfo, mcast_stream_emptyspeed*1000); - /* sliding window and buffercalc for all groups */ - slidingwindow(tapinfo->allstreams, pinfo); - buffusagecalc(tapinfo->allstreams, pinfo, mcast_stream_cumulemptyspeed*1000); - /* end of sliding window */ - - return 1; /* refresh output */ - -} - -/****************************************************************************/ -/* scan for Mcast streams */ -void -mcaststream_scan(void) -{ - gboolean was_registered = the_tapinfo_struct.is_registered; - if (!the_tapinfo_struct.is_registered) - register_tap_listener_mcast_stream(); - - cf_retap_packets(&cfile); - - if (!was_registered) - remove_tap_listener_mcast_stream(); -} - - -/****************************************************************************/ -const mcaststream_tapinfo_t * -mcaststream_get_info(void) -{ - return &the_tapinfo_struct; -} - - -/****************************************************************************/ -/* TAP INTERFACE */ -/****************************************************************************/ - -/****************************************************************************/ -void -remove_tap_listener_mcast_stream(void) -{ - if (the_tapinfo_struct.is_registered) { - remove_tap_listener(&the_tapinfo_struct); - - the_tapinfo_struct.is_registered = FALSE; - } -} - - -/****************************************************************************/ -void -register_tap_listener_mcast_stream(void) -{ - GString *error_string; - if (!the_tapinfo_struct.is_registered) { - error_string = register_tap_listener("udp", &the_tapinfo_struct, - NULL, 0, mcaststream_reset_cb, mcaststream_packet, - mcaststream_draw); - - if (error_string != NULL) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "%s", error_string->str); - g_string_free(error_string, TRUE); - exit(1); - } - - the_tapinfo_struct.is_registered = TRUE; - } -} - -/*******************************************************************************/ -/* sliding window and buffer calculations */ - -/* compare two times */ -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 */ -static void -buffusagecalc(mcast_stream_info_t *strinfo, packet_info *pinfo, double emptyspeed_lcl) -{ - time_t sec=0; - gint32 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; - } - - sec = buffer[cur].tv_sec - buffer[prev].tv_sec; - usec = (gint32)buffer[cur].tv_usec - (gint32)buffer[prev].tv_usec; - timeelapsed = (double)usec/1000000 + (double)sec; - - /* bytes added to buffer */ - strinfo->element.buffusage+=pinfo->fd->pkt_len; - - /* 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 >= 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; -} - -/* sliding window calculation */ -static void -slidingwindow(mcast_stream_info_t *strinfo, packet_info *pinfo) -{ - struct timeval *buffer; - gint32 diff; - - buffer = strinfo->element.buff; - - 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; - } - - /* burst count */ - buffer[strinfo->element.last].tv_sec = (guint32) pinfo->rel_ts.secs; - buffer[strinfo->element.last].tv_usec = pinfo->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 >= 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++; -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/ui/gtk/mcast_stream.h b/ui/gtk/mcast_stream.h deleted file mode 100644 index 094e27d683..0000000000 --- a/ui/gtk/mcast_stream.h +++ /dev/null @@ -1,147 +0,0 @@ -/* mcast_stream.h - * - * Copyright 2006, Iskratel , Slovenia - * By Jakob Bratkovic <j.bratkovic@iskratel.si> and - * Miha Jemec <m.jemec@iskratel.si> - * - * based on rtp_stream.h - * Copyright 2003, Alcatel Business Systems - * By Lars Ruoff <lars.ruoff@gmx.net> - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __MCAST_STREAM_H__ -#define __MCAST_STREAM_H__ - -#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 */ -} t_buffer; - - -/* defines an mcast stream */ -typedef struct _mcast_stream_info { - address src_addr; - guint16 src_port; - address dest_addr; - guint16 dest_port; - guint32 npackets; - guint32 apackets; - guint32 total_bytes; - float average_bw; - - guint32 first_frame_num; /* frame number of first frame */ - /* start of recording (GMT) of this stream */ - guint32 start_sec; /* seconds */ - guint32 start_usec; /* microseconds */ - guint32 start_rel_sec; /* start stream rel seconds */ - guint32 start_rel_usec; /* start stream rel microseconds */ - 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; - -} mcast_stream_info_t; - - -/* structure that holds the information about all detected streams */ -/* struct holding all information of the tap */ -typedef struct _mcaststream_tapinfo { - int nstreams; /* number of streams in the list */ - GList* strinfo_list; /* list with all streams */ - guint32 npackets; /* total number of mcast packets of all streams */ - mcast_stream_info_t* allstreams; /* structure holding information common for all streams */ - - guint32 launch_count; /* number of times the tap has been run */ - 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 */ - -/* -* Registers the mcast_streams tap listener (if not already done). -* From that point on, the Mcast streams list will be updated with every redissection. -* This function is also the entry point for the initialization routine of the tap system. -* So whenever mcast_stream.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup. -* If not, it will be registered on demand by the mcast_streams and mcast_analysis functions that need it. -*/ -void register_tap_listener_mcast_stream(void); - -/* -* Removes the mcast_streams tap listener (if not already done) -* From that point on, the Mcast streams list won't be updated any more. -*/ -void remove_tap_listener_mcast_stream(void); - -/* -* Retrieves a constant reference to the unique info structure of the mcast_streams tap listener. -* The user should not modify the data pointed to. -*/ -const mcaststream_tapinfo_t* mcaststream_get_info(void); - -/* -* Cleans up memory of mcast streams tap. -*/ -void mcaststream_reset(mcaststream_tapinfo_t *tapinfo); - -/* -* Scans all packets for Mcast streams and updates the Mcast streams list. -* (redissects all packets) -*/ -void mcaststream_scan(void); - -#endif /* __MCAST_STREAM_H__ */ - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/ui/gtk/mcast_stream_dlg.c b/ui/gtk/mcast_stream_dlg.c index 38bc341dc4..716a4eb305 100644 --- a/ui/gtk/mcast_stream_dlg.c +++ b/ui/gtk/mcast_stream_dlg.c @@ -43,14 +43,21 @@ #include "ui/gtk/gui_stat_menu.h" #include "ui/gtk/mcast_stream_dlg.h" -#include "ui/gtk/mcast_stream.h" #include "ui/gtk/dlg_utils.h" #include "ui/gtk/gui_utils.h" #include "ui/gtk/gtkglobals.h" #include "ui/gtk/stock_icons.h" +static void mcaststream_dlg_update(void *ti_ptr); + void register_tap_listener_mcast_stream_dlg(void); +/****************************************************************************/ +/* the one and only global mcaststream_tapinfo_t structure for tshark and wireshark. + */ +static mcaststream_tapinfo_t the_tapinfo_struct = + {mcaststream_dlg_update, 0, NULL, 0, NULL, 0, FALSE}; + /* Capture callback data keys */ #define E_MCAST_ENTRY_1 "burst_interval" #define E_MCAST_ENTRY_2 "burst_alarm" @@ -103,14 +110,14 @@ static void mcaststream_on_destroy(GObject *object _U_, gpointer user_data _U_) { /* Remove the stream tap listener */ - remove_tap_listener_mcast_stream(); + remove_tap_listener_mcast_stream(&the_tapinfo_struct); /* Is there a params window open? */ if (mcast_params_dlg != NULL) window_destroy(mcast_params_dlg); /* Clean up memory used by stream tap */ - mcaststream_reset((mcaststream_tapinfo_t*)mcaststream_get_info()); + mcaststream_reset(mcaststream_dlg_get_tapinfo()); /* Note that we no longer have a "Mcast Streams" dialog box. */ mcast_stream_dlg = NULL; @@ -166,7 +173,7 @@ mcaststream_on_filter(GtkButton *button _U_, gpointer user_data _U_) #if 0 main_filter_packets(&cfile, filter_string, FALSE); - mcaststream_dlg_update(mcaststream_get_info()->strinfo_list); + mcaststream_dlg_update(mcaststream_dlg_get_tapinfo()->strinfo_list); #endif } @@ -269,7 +276,7 @@ mcast_params_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) window_destroy(GTK_WIDGET(parent_w)); /* Clean up memory used by stream tap */ - mcaststream_reset((mcaststream_tapinfo_t*)mcaststream_get_info()); + mcaststream_reset((mcaststream_tapinfo_t*)mcaststream_dlg_get_tapinfo()); /* retap all packets */ cf_retap_packets(&cfile); @@ -431,9 +438,9 @@ add_to_list_store(mcast_stream_info_t* strinfo) g_snprintf(label_text, sizeof(label_text), "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, mcast_stream_burstint, - (float)(mcaststream_get_info()->allstreams->element.topbuffusage)/1000); + mcaststream_dlg_get_tapinfo()->allstreams->average_bw, mcaststream_dlg_get_tapinfo()->allstreams->element.maxbw, + mcaststream_dlg_get_tapinfo()->allstreams->element.topburstsize, mcast_stream_burstint, + (float)(mcaststream_dlg_get_tapinfo()->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", @@ -743,8 +750,17 @@ 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) +mcaststream_dlg_update(void *ti_ptr) { + GList *list; + mcaststream_tapinfo_t *tapinfo = (mcaststream_tapinfo_t *)ti_ptr; + + if (!tapinfo) { + return; + } + + list = tapinfo->strinfo_list; + if (mcast_stream_dlg != NULL) { gtk_list_store_clear(list_store); streams_nb = 0; @@ -762,6 +778,14 @@ mcaststream_dlg_update(GList *list) last_list = list; } +#if 0 +static void +mcaststream_dlg_mark_packet(mcaststream_tapinfo_t *tapinfo _U_, frame_data *fd) { + if (!fd) return; + + cf_mark_frame(&cfile, fd); +} +#endif /****************************************************************************/ /* update the contents of the dialog box clist */ @@ -791,13 +815,13 @@ void mcaststream_launch(GtkAction *action _U_, gpointer user_data _U_) { /* Register the tap listener */ - register_tap_listener_mcast_stream(); + register_tap_listener_mcast_stream(&the_tapinfo_struct); /* Scan for Mcast streams (redissect all packets) */ - mcaststream_scan(); + mcaststream_scan(&the_tapinfo_struct, &cfile); /* Show the dialog box with the list of streams */ - mcaststream_dlg_show(mcaststream_get_info()->strinfo_list); + mcaststream_dlg_show(the_tapinfo_struct.strinfo_list); /* Tap listener will be removed and cleaned up in mcaststream_on_destroy */ } @@ -808,6 +832,10 @@ register_tap_listener_mcast_stream_dlg(void) { } +mcaststream_tapinfo_t *mcaststream_dlg_get_tapinfo(void) { + return &the_tapinfo_struct; +} + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/ui/gtk/mcast_stream_dlg.h b/ui/gtk/mcast_stream_dlg.h index f64106ba76..819d09d3a9 100644 --- a/ui/gtk/mcast_stream_dlg.h +++ b/ui/gtk/mcast_stream_dlg.h @@ -30,6 +30,8 @@ #ifndef __MCAST_STREAM_DLG_H__ #define __MCAST_STREAM_DLG_H__ +#include "ui/mcast_stream.h" + /** @file * @ingroup dialog_group * "Mcast Stream Analysis" dialog box. @@ -43,10 +45,12 @@ void mcaststream_dlg_show(GList *list); /** - * Update the contents of the dialog box clist with that of list. + * Retrieves a constant reference to the unique info structure of the + * rtp_streams tap listener. + * The user should not modify the data pointed to. * - * @param list pointer to list of mcast_stream_info_t* + * @return Pointer to an rtpstream_tapinfo_t */ -void mcaststream_dlg_update(GList *list); +mcaststream_tapinfo_t *mcaststream_dlg_get_tapinfo(void); #endif /* __MCAST_STREAM_DLG_H__ */ |