2003-09-24 07:48:12 +00:00
/* rtp_analysis.c
2006-05-22 07:29:40 +00:00
* RTP analysis addition for Wireshark
2003-09-24 07:48:12 +00:00
*
2004-07-18 00:24:25 +00:00
* $ Id $
2003-09-24 07:48:12 +00:00
*
* Copyright 2003 , Alcatel Business Systems
* By Lars Ruoff < lars . ruoff @ gmx . net >
*
* based on tap_rtp . c
* Copyright 2003 , Iskratel , Ltd , Kranj
* By Miha Jemec < m . jemec @ iskratel . si >
*
2004-10-01 07:14:50 +00:00
* Graph . Copyright 2004 , Verso Technology
* By Alejandro Vaquero < alejandro . vaquero @ verso . com >
2007-05-17 18:41:07 +00:00
* Based on io_stat . c by Ronnie Sahlberg
2004-10-01 07:14:50 +00:00
*
2006-05-21 05:12:17 +00:00
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
2003-09-24 07:48:12 +00:00
* 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 . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
2008-04-13 03:32:24 +00:00
# include <math.h>
# include <string.h>
# include <locale.h>
2003-09-24 07:48:12 +00:00
2008-04-13 03:32:24 +00:00
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
2003-09-24 07:48:12 +00:00
2008-04-13 03:32:24 +00:00
# ifdef HAVE_FCNTL_H
# include <fcntl.h>
2003-09-24 07:48:12 +00:00
# endif
2008-04-13 03:32:24 +00:00
# include <gtk/gtk.h>
2004-02-13 00:53:37 +00:00
# include <epan/epan_dissect.h>
# include <epan/filesystem.h>
2007-12-28 13:01:55 +00:00
# include <epan/pint.h>
2004-09-29 00:06:36 +00:00
# include <epan/tap.h>
2004-07-18 18:06:47 +00:00
# include <epan/dissectors/packet-rtp.h>
2005-09-17 00:02:31 +00:00
# include <epan/rtp_pt.h>
2005-03-02 23:22:11 +00:00
# include <epan/addr_resolv.h>
2005-08-20 20:06:05 +00:00
# include <epan/stat_cmd_args.h>
2008-04-13 03:32:24 +00:00
# include <epan/strutil.h>
# include "../util.h"
# include "../register.h"
# include "../g711.h"
# include "../alert_box.h"
# include "../simple_dialog.h"
2005-08-21 09:48:27 +00:00
# include "../stat_menu.h"
2008-04-13 03:32:24 +00:00
# include "../progress_dlg.h"
2004-10-01 07:14:50 +00:00
# include "../color.h"
2008-04-13 03:32:24 +00:00
# include "../tempfile.h"
2008-05-22 15:46:27 +00:00
# include <wsutil/file_util.h>
2008-04-13 03:32:24 +00:00
# include "gtk/gtkglobals.h"
# include "gtk/dlg_utils.h"
# include "gtk/file_dlg.h"
# include "gtk/gui_utils.h"
# include "gtk/gui_stat_menu.h"
# include "gtk/main.h"
# include "gtk/rtp_analysis.h"
# include "gtk/rtp_stream.h"
# include "gtk/rtp_stream_dlg.h"
2003-09-24 07:48:12 +00:00
2009-02-20 17:13:44 +00:00
enum
{
PACKET_COLUMN ,
SEQUENCE_COLUMN ,
DELTA_COLUMN ,
JITTER_COLUMN ,
IPBW_COLUMN ,
MARKER_COLUMN ,
STATUS_COLUMN ,
DATE_COLUMN ,
LENGTH_COLUMN ,
FOREGROUND_COLOR_COL ,
BACKGROUND_COLOR_COL ,
N_COLUMN /* The number of columns */
} ;
2003-09-24 07:48:12 +00:00
/****************************************************************************/
2004-10-11 05:23:31 +00:00
# define NUM_COLS 9
2004-10-01 07:14:50 +00:00
# define NUM_GRAPH_ITEMS 100000
# define MAX_YSCALE 16
# define AUTO_MAX_YSCALE 0
# define MAX_GRAPHS 4
# define GRAPH_FWD_JITTER 0
# define GRAPH_FWD_DIFF 1
# define GRAPH_REV_JITTER 2
# define GRAPH_REV_DIFF 3
static guint32 yscale_max [ MAX_YSCALE ] = { AUTO_MAX_YSCALE , 1000 , 2000 , 5000 , 10000 , 20000 , 50000 , 100000 , 200000 , 500000 , 1000000 , 2000000 , 5000000 , 10000000 , 20000000 , 50000000 } ;
# define MAX_PIXELS_PER_TICK 4
# define DEFAULT_PIXELS_PER_TICK 1
static guint32 pixels_per_tick [ MAX_PIXELS_PER_TICK ] = { 1 , 2 , 5 , 10 } ;
2005-08-06 14:03:14 +00:00
static const char * graph_descr [ 4 ] = { " Fwd Jitter " , " Fwd Difference " , " Rvr Jitter " , " Rvr Difference " } ;
2004-10-01 07:14:50 +00:00
/* unit is in ms */
# define MAX_TICK_VALUES 5
# define DEFAULT_TICK_VALUE 1
static guint tick_interval_values [ MAX_TICK_VALUES ] = { 1 , 10 , 100 , 1000 , 10000 } ;
typedef struct _dialog_graph_graph_item_t {
guint32 value ;
guint32 flags ;
} dialog_graph_graph_item_t ;
typedef struct _dialog_graph_graph_t {
2007-05-17 18:41:07 +00:00
struct _user_data_t * ud ;
2004-10-01 07:14:50 +00:00
dialog_graph_graph_item_t items [ NUM_GRAPH_ITEMS ] ;
int plot_style ;
gboolean display ;
GtkWidget * display_button ;
int hf_index ;
GdkColor color ;
GdkGC * gc ;
gchar title [ 100 ] ;
} dialog_graph_graph_t ;
typedef struct _dialog_graph_t {
gboolean needs_redraw ;
gint32 interval ; /* measurement interval in ms */
guint32 last_interval ;
guint32 max_interval ; /* XXX max_interval and num_items are redundant */
guint32 num_items ;
struct _dialog_graph_graph_t graph [ MAX_GRAPHS ] ;
GtkWidget * window ;
GtkWidget * draw_area ;
GdkPixmap * pixmap ;
GtkAdjustment * scrollbar_adjustment ;
GtkWidget * scrollbar ;
int pixmap_width ;
int pixmap_height ;
int pixels_per_tick ;
int max_y_units ;
double start_time ;
2007-05-17 18:41:07 +00:00
} dialog_graph_t ;
2004-10-01 07:14:50 +00:00
2003-09-24 07:48:12 +00:00
typedef struct _dialog_data_t {
GtkWidget * window ;
2009-02-20 17:13:44 +00:00
GtkWidget * list_fwd ;
GtkTreeIter iter ;
GtkWidget * list_rev ;
2003-09-24 07:48:12 +00:00
GtkWidget * label_stats_fwd ;
GtkWidget * label_stats_rev ;
2009-02-20 17:13:44 +00:00
GtkWidget * selected_list ;
guint number_of_nok ;
GtkTreeSelection * selected_list_sel ;
gint selected_list_row ;
2003-09-24 07:48:12 +00:00
GtkWidget * notebook ;
GtkWidget * save_voice_as_w ;
GtkWidget * save_csv_as_w ;
2004-10-01 07:14:50 +00:00
gint notebook_signal_id ;
2009-02-20 17:13:44 +00:00
dialog_graph_t dialog_graph ;
2003-09-24 07:48:12 +00:00
# ifdef USE_CONVERSATION_GRAPH
GtkWidget * graph_window ;
# endif
} dialog_data_t ;
2004-01-24 01:15:24 +00:00
# define OK_TEXT "[ Ok ]"
2004-07-17 10:14:03 +00:00
2003-09-24 07:48:12 +00:00
/* type of error when saving voice in a file didn't succeed */
typedef enum {
TAP_RTP_WRONG_CODEC ,
TAP_RTP_WRONG_LENGTH ,
TAP_RTP_PADDING_ERROR ,
2004-01-31 09:48:26 +00:00
TAP_RTP_SHORT_FRAME ,
2003-09-24 07:48:12 +00:00
TAP_RTP_FILE_OPEN_ERROR ,
TAP_RTP_NO_DATA
2007-05-17 18:41:07 +00:00
} error_type_t ;
2003-09-24 07:48:12 +00:00
2003-09-25 19:35:14 +00:00
typedef struct _tap_rtp_save_info_t {
2003-09-24 07:48:12 +00:00
FILE * fp ;
guint32 count ;
error_type_t error_type ;
gboolean saved ;
2003-09-25 19:35:14 +00:00
} tap_rtp_save_info_t ;
/* structure that holds the information about the forward and reversed direction */
struct _info_direction {
tap_rtp_stat_t statinfo ;
tap_rtp_save_info_t saveinfo ;
2003-09-24 07:48:12 +00:00
} ;
2003-09-29 19:20:51 +00:00
# define TMPNAMSIZE 100
2005-10-29 15:34:16 +00:00
# define SILENCE_PCMU (guint8)0xFF
# define SILENCE_PCMA (guint8)0x55
2007-05-17 18:41:07 +00:00
/* structure that holds general information about the connection
2003-09-24 07:48:12 +00:00
* and structures for both directions */
typedef struct _user_data_t {
/* tap associated data*/
2004-12-01 11:54:41 +00:00
address ip_src_fwd ;
2003-09-24 07:48:12 +00:00
guint16 port_src_fwd ;
2004-12-01 11:54:41 +00:00
address ip_dst_fwd ;
2003-09-24 07:48:12 +00:00
guint16 port_dst_fwd ;
guint32 ssrc_fwd ;
2004-12-01 11:54:41 +00:00
address ip_src_rev ;
2003-09-24 07:48:12 +00:00
guint16 port_src_rev ;
2004-12-01 11:54:41 +00:00
address ip_dst_rev ;
2003-09-24 07:48:12 +00:00
guint16 port_dst_rev ;
guint32 ssrc_rev ;
struct _info_direction forward ;
struct _info_direction reversed ;
2003-09-29 19:20:51 +00:00
char f_tempname [ TMPNAMSIZE ] ;
char r_tempname [ TMPNAMSIZE ] ;
2003-09-24 07:48:12 +00:00
/* dialog associated data */
dialog_data_t dlg ;
# ifdef USE_CONVERSATION_GRAPH
time_series_t series_fwd ;
time_series_t series_rev ;
# endif
} user_data_t ;
2004-01-25 02:14:05 +00:00
/* Column titles. */
2005-08-06 14:03:14 +00:00
static const gchar * titles [ 9 ] = {
2004-01-25 02:14:05 +00:00
" Packet " ,
" Sequence " ,
2004-12-01 11:54:41 +00:00
" Delta (ms) " ,
2004-10-01 07:14:50 +00:00
" Jitter (ms) " ,
2004-10-11 05:23:31 +00:00
" IP BW (kbps) " ,
2004-01-25 02:14:05 +00:00
" Marker " ,
" Status " ,
" Date " ,
" Length "
} ;
2005-09-01 05:41:59 +00:00
# define SAVE_FORWARD_DIRECTION_MASK 0x01
2007-05-17 18:41:07 +00:00
# define SAVE_REVERSE_DIRECTION_MASK 0x02
# define SAVE_BOTH_DIRECTION_MASK (SAVE_FORWARD_DIRECTION_MASK|SAVE_REVERSE_DIRECTION_MASK)
2005-09-01 05:41:59 +00:00
2006-03-07 16:39:54 +00:00
# define SAVE_NONE_FORMAT 0
# define SAVE_WAV_FORMAT 1
2005-09-01 05:41:59 +00:00
# define SAVE_AU_FORMAT 2
2006-03-07 16:39:54 +00:00
# define SAVE_SW_FORMAT 3
2005-09-01 05:41:59 +00:00
# define SAVE_RAW_FORMAT 4
2004-01-25 02:14:05 +00:00
2004-10-01 07:14:50 +00:00
static void on_refresh_bt_clicked ( GtkWidget * bt _U_ , user_data_t * user_data _U_ ) ;
/****************************************************************************/
static void enable_graph ( dialog_graph_graph_t * dgg )
{
2007-05-17 18:41:07 +00:00
2004-10-01 07:14:50 +00:00
dgg - > display = TRUE ;
}
static void dialog_graph_reset ( user_data_t * user_data ) ;
2003-09-24 07:48:12 +00:00
2004-12-01 11:54:41 +00:00
2003-09-24 07:48:12 +00:00
/****************************************************************************/
/* TAP FUNCTIONS */
/****************************************************************************/
/* when there is a [re]reading of packet's */
static void
2004-01-23 00:29:52 +00:00
rtp_reset ( void * user_data_arg )
2003-09-24 07:48:12 +00:00
{
2004-01-23 00:29:52 +00:00
user_data_t * user_data = user_data_arg ;
2003-09-25 19:35:14 +00:00
user_data - > forward . statinfo . first_packet = TRUE ;
user_data - > reversed . statinfo . first_packet = TRUE ;
2004-12-01 11:54:41 +00:00
user_data - > forward . statinfo . max_delta = 0 ;
user_data - > reversed . statinfo . max_delta = 0 ;
2005-02-16 09:24:52 +00:00
user_data - > forward . statinfo . max_jitter = 0 ;
user_data - > reversed . statinfo . max_jitter = 0 ;
user_data - > forward . statinfo . mean_jitter = 0 ;
user_data - > reversed . statinfo . mean_jitter = 0 ;
2004-12-01 11:54:41 +00:00
user_data - > forward . statinfo . delta = 0 ;
user_data - > reversed . statinfo . delta = 0 ;
2005-03-29 10:58:08 +00:00
user_data - > forward . statinfo . diff = 0 ;
user_data - > reversed . statinfo . diff = 0 ;
2003-09-25 19:35:14 +00:00
user_data - > forward . statinfo . jitter = 0 ;
user_data - > reversed . statinfo . jitter = 0 ;
2004-10-11 05:23:31 +00:00
user_data - > forward . statinfo . bandwidth = 0 ;
user_data - > reversed . statinfo . bandwidth = 0 ;
user_data - > forward . statinfo . total_bytes = 0 ;
user_data - > reversed . statinfo . total_bytes = 0 ;
user_data - > forward . statinfo . bw_start_index = 0 ;
user_data - > reversed . statinfo . bw_start_index = 0 ;
user_data - > forward . statinfo . bw_index = 0 ;
user_data - > reversed . statinfo . bw_index = 0 ;
2003-09-25 19:35:14 +00:00
user_data - > forward . statinfo . timestamp = 0 ;
user_data - > reversed . statinfo . timestamp = 0 ;
user_data - > forward . statinfo . max_nr = 0 ;
user_data - > reversed . statinfo . max_nr = 0 ;
user_data - > forward . statinfo . total_nr = 0 ;
user_data - > reversed . statinfo . total_nr = 0 ;
user_data - > forward . statinfo . sequence = 0 ;
user_data - > reversed . statinfo . sequence = 0 ;
user_data - > forward . statinfo . start_seq_nr = 0 ;
user_data - > reversed . statinfo . start_seq_nr = 1 ; /* 1 is ok (for statistics in reversed direction) */
user_data - > forward . statinfo . stop_seq_nr = 0 ;
user_data - > reversed . statinfo . stop_seq_nr = 0 ;
user_data - > forward . statinfo . cycles = 0 ;
user_data - > reversed . statinfo . cycles = 0 ;
user_data - > forward . statinfo . under = FALSE ;
user_data - > reversed . statinfo . under = FALSE ;
user_data - > forward . statinfo . start_time = 0 ;
user_data - > reversed . statinfo . start_time = 0 ;
user_data - > forward . statinfo . time = 0 ;
user_data - > reversed . statinfo . time = 0 ;
2004-01-24 01:15:24 +00:00
user_data - > forward . statinfo . reg_pt = PT_UNDEFINED ;
user_data - > reversed . statinfo . reg_pt = PT_UNDEFINED ;
2003-09-25 19:35:14 +00:00
user_data - > forward . saveinfo . count = 0 ;
user_data - > reversed . saveinfo . count = 0 ;
user_data - > forward . saveinfo . saved = FALSE ;
user_data - > reversed . saveinfo . saved = FALSE ;
2003-09-24 07:48:12 +00:00
2009-02-20 17:13:44 +00:00
/* clear the dialog box lists */
gtk_list_store_clear ( GTK_LIST_STORE ( gtk_tree_view_get_model ( GTK_TREE_VIEW ( user_data - > dlg . list_fwd ) ) ) ) ;
gtk_list_store_clear ( GTK_LIST_STORE ( gtk_tree_view_get_model ( GTK_TREE_VIEW ( user_data - > dlg . list_rev ) ) ) ) ;
2004-10-01 07:14:50 +00:00
/* reset graph info */
dialog_graph_reset ( user_data ) ;
2003-09-24 07:48:12 +00:00
# ifdef USE_CONVERSATION_GRAPH
if ( user_data - > dlg . graph_window ! = NULL )
2004-05-26 03:49:24 +00:00
window_destroy ( user_data - > dlg . graph_window ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
g_array_free ( user_data - > series_fwd . value_pairs , TRUE ) ;
user_data - > series_fwd . value_pairs = g_array_new ( FALSE , FALSE , sizeof ( value_pair_t ) ) ;
g_array_free ( user_data - > series_rev . value_pairs , TRUE ) ;
user_data - > series_rev . value_pairs = g_array_new ( FALSE , FALSE , sizeof ( value_pair_t ) ) ;
# endif
/* XXX check for error at fclose? */
2003-09-25 19:35:14 +00:00
if ( user_data - > forward . saveinfo . fp ! = NULL )
2007-05-17 18:41:07 +00:00
fclose ( user_data - > forward . saveinfo . fp ) ;
2003-09-25 19:35:14 +00:00
if ( user_data - > reversed . saveinfo . fp ! = NULL )
2007-05-17 18:41:07 +00:00
fclose ( user_data - > reversed . saveinfo . fp ) ;
2008-05-22 15:46:27 +00:00
user_data - > forward . saveinfo . fp = ws_fopen ( user_data - > f_tempname , " wb " ) ;
2003-09-25 19:35:14 +00:00
if ( user_data - > forward . saveinfo . fp = = NULL )
user_data - > forward . saveinfo . error_type = TAP_RTP_FILE_OPEN_ERROR ;
2008-05-22 15:46:27 +00:00
user_data - > reversed . saveinfo . fp = ws_fopen ( user_data - > r_tempname , " wb " ) ;
2003-09-25 19:35:14 +00:00
if ( user_data - > reversed . saveinfo . fp = = NULL )
user_data - > reversed . saveinfo . error_type = TAP_RTP_FILE_OPEN_ERROR ;
2003-09-24 07:48:12 +00:00
return ;
}
2004-10-01 07:14:50 +00:00
/****************************************************************************/
2004-10-05 08:51:16 +00:00
static int rtp_packet_add_graph ( dialog_graph_graph_t * dgg , tap_rtp_stat_t * statinfo , packet_info * pinfo , guint32 value )
2004-10-01 07:14:50 +00:00
{
2005-03-29 10:58:08 +00:00
dialog_graph_graph_item_t * it ;
int idx ;
2004-10-01 07:14:50 +00:00
double rtp_time ;
2005-03-29 10:58:08 +00:00
/* we sometimes get called when dgg is disabled.
this is a bug since the tap listener should be removed first */
if ( ! dgg - > display ) {
return 0 ;
}
2004-10-01 07:14:50 +00:00
2005-03-29 10:58:08 +00:00
dgg - > ud - > dlg . dialog_graph . needs_redraw = TRUE ;
2004-10-01 07:14:50 +00:00
2005-03-29 10:58:08 +00:00
/*
* Find which interval this is supposed to to in and store the
* interval index as idx
*/
2004-10-01 07:14:50 +00:00
if ( dgg - > ud - > dlg . dialog_graph . start_time = = - 1 ) { /* it is the first */
dgg - > ud - > dlg . dialog_graph . start_time = statinfo - > start_time ;
2005-03-29 10:58:08 +00:00
}
2005-08-24 21:31:56 +00:00
rtp_time = nstime_to_sec ( & pinfo - > fd - > rel_ts ) - dgg - > ud - > dlg . dialog_graph . start_time ;
2004-10-01 07:14:50 +00:00
if ( rtp_time < 0 ) {
return FALSE ;
2005-03-29 10:58:08 +00:00
}
2004-10-01 07:14:50 +00:00
idx = ( guint32 ) ( rtp_time * 1000 ) / dgg - > ud - > dlg . dialog_graph . interval ;
2005-03-29 10:58:08 +00:00
/* some sanity checks */
if ( ( idx < 0 ) | | ( idx > = NUM_GRAPH_ITEMS ) ) {
return FALSE ;
}
2004-10-01 07:14:50 +00:00
2005-03-29 10:58:08 +00:00
/* update num_items */
if ( ( guint32 ) idx > dgg - > ud - > dlg . dialog_graph . num_items ) {
dgg - > ud - > dlg . dialog_graph . num_items = idx ;
dgg - > ud - > dlg . dialog_graph . max_interval = idx * dgg - > ud - > dlg . dialog_graph . interval ;
}
2004-10-01 07:14:50 +00:00
2005-03-29 10:58:08 +00:00
/*
* Find the appropriate dialog_graph_graph_item_t structure
*/
it = & dgg - > items [ idx ] ;
2004-10-01 07:14:50 +00:00
/*
2005-03-29 10:58:08 +00:00
* Use the max value to highlight RTP problems
*/
2004-10-01 07:14:50 +00:00
if ( value > it - > value ) {
it - > value = value ;
}
it - > flags = it - > flags | statinfo - > flags ;
2005-03-29 10:58:08 +00:00
return TRUE ;
2004-10-01 07:14:50 +00:00
}
2003-09-24 07:48:12 +00:00
/****************************************************************************/
/* here we can redraw the output */
/* not used yet */
static void rtp_draw ( void * prs _U_ )
{
return ;
}
2003-09-25 19:35:14 +00:00
/* forward declarations */
2009-02-20 17:13:44 +00:00
static void add_to_list ( GtkWidget * list , user_data_t * user_data , guint32 number , guint16 seq_num ,
2004-12-01 11:54:41 +00:00
double delta , double jitter , double bandwidth , gchar * status , gboolean marker ,
2009-02-20 17:13:44 +00:00
gchar * timeStr , guint32 pkt_len , gchar * color_str , guint32 flags ) ;
2003-09-25 19:35:14 +00:00
2009-02-20 17:13:44 +00:00
static int rtp_packet_add_info ( GtkWidget * list , user_data_t * user_data ,
2005-01-01 02:57:02 +00:00
tap_rtp_stat_t * statinfo , packet_info * pinfo ,
const struct _rtp_info * rtpinfo ) ;
2005-02-16 09:24:52 +00:00
2007-05-17 18:41:07 +00:00
static int rtp_packet_save_payload ( tap_rtp_save_info_t * saveinfo ,
2005-01-01 02:57:02 +00:00
tap_rtp_stat_t * statinfo ,
packet_info * pinfo ,
const struct _rtp_info * rtpinfo ) ;
2003-09-25 19:35:14 +00:00
2003-09-24 07:48:12 +00:00
/****************************************************************************/
/* whenever a RTP packet is seen by the tap listener */
2005-01-01 02:57:02 +00:00
static int rtp_packet ( void * user_data_arg , packet_info * pinfo , epan_dissect_t * edt _U_ , const void * rtpinfo_arg )
2003-09-24 07:48:12 +00:00
{
2004-01-23 00:29:52 +00:00
user_data_t * user_data = user_data_arg ;
2005-01-01 02:57:02 +00:00
const struct _rtp_info * rtpinfo = rtpinfo_arg ;
2003-09-24 07:48:12 +00:00
# ifdef USE_CONVERSATION_GRAPH
value_pair_t vp ;
# endif
/* we ignore packets that are not displayed */
if ( pinfo - > fd - > flags . passed_dfilter = = 0 )
return 0 ;
2004-10-17 22:14:47 +00:00
/* also ignore RTP Version != 2 */
else if ( rtpinfo - > info_version ! = 2 )
return 0 ;
2003-09-24 07:48:12 +00:00
/* is it the forward direction? */
2005-03-29 10:58:08 +00:00
else if ( user_data - > ssrc_fwd = = rtpinfo - > info_sync_src
& & CMP_ADDRESS ( & ( user_data - > ip_src_fwd ) , & ( pinfo - > net_src ) ) = = 0
& & user_data - > port_src_fwd = = pinfo - > srcport
& & CMP_ADDRESS ( & ( user_data - > ip_dst_fwd ) , & ( pinfo - > net_dst ) ) = = 0
& & user_data - > port_dst_fwd = = pinfo - > destport ) {
2003-09-24 07:48:12 +00:00
# ifdef USE_CONVERSATION_GRAPH
vp . time = ( ( double ) pinfo - > fd - > rel_secs + ( double ) pinfo - > fd - > rel_usecs / 1000000 ) ;
vp . fnumber = pinfo - > fd - > num ;
g_array_append_val ( user_data - > series_fwd . value_pairs , vp ) ;
# endif
2003-09-25 19:35:14 +00:00
rtp_packet_analyse ( & ( user_data - > forward . statinfo ) , pinfo , rtpinfo ) ;
2004-10-05 08:51:16 +00:00
rtp_packet_add_graph ( & ( user_data - > dlg . dialog_graph . graph [ GRAPH_FWD_JITTER ] ) , & ( user_data - > forward . statinfo ) , pinfo , ( guint32 ) ( user_data - > forward . statinfo . jitter * 1000000 ) ) ;
rtp_packet_add_graph ( & ( user_data - > dlg . dialog_graph . graph [ GRAPH_FWD_DIFF ] ) , & ( user_data - > forward . statinfo ) , pinfo , ( guint32 ) ( user_data - > forward . statinfo . diff * 1000000 ) ) ;
2009-02-20 17:13:44 +00:00
rtp_packet_add_info ( user_data - > dlg . list_fwd , user_data ,
2003-09-25 19:35:14 +00:00
& ( user_data - > forward . statinfo ) , pinfo , rtpinfo ) ;
rtp_packet_save_payload ( & ( user_data - > forward . saveinfo ) ,
& ( user_data - > forward . statinfo ) , pinfo , rtpinfo ) ;
2003-09-24 07:48:12 +00:00
}
/* is it the reversed direction? */
2005-03-29 10:58:08 +00:00
else if ( user_data - > ssrc_rev = = rtpinfo - > info_sync_src
& & CMP_ADDRESS ( & ( user_data - > ip_src_rev ) , & ( pinfo - > net_src ) ) = = 0
& & user_data - > port_src_rev = = pinfo - > srcport
& & CMP_ADDRESS ( & ( user_data - > ip_dst_rev ) , & ( pinfo - > net_dst ) ) = = 0
& & user_data - > port_dst_rev = = pinfo - > destport ) {
2003-09-24 07:48:12 +00:00
# ifdef USE_CONVERSATION_GRAPH
vp . time = ( ( double ) pinfo - > fd - > rel_secs + ( double ) pinfo - > fd - > rel_usecs / 1000000 ) ;
vp . fnumber = pinfo - > fd - > num ;
g_array_append_val ( user_data - > series_rev . value_pairs , vp ) ;
# endif
2003-09-25 19:35:14 +00:00
rtp_packet_analyse ( & ( user_data - > reversed . statinfo ) , pinfo , rtpinfo ) ;
2004-10-05 08:51:16 +00:00
rtp_packet_add_graph ( & ( user_data - > dlg . dialog_graph . graph [ GRAPH_REV_JITTER ] ) , & ( user_data - > reversed . statinfo ) , pinfo , ( guint32 ) ( user_data - > reversed . statinfo . jitter * 1000000 ) ) ;
rtp_packet_add_graph ( & ( user_data - > dlg . dialog_graph . graph [ GRAPH_REV_DIFF ] ) , & ( user_data - > reversed . statinfo ) , pinfo , ( guint32 ) ( user_data - > reversed . statinfo . diff * 1000000 ) ) ;
2009-02-20 17:13:44 +00:00
rtp_packet_add_info ( user_data - > dlg . list_rev , user_data ,
2003-09-25 19:35:14 +00:00
& ( user_data - > reversed . statinfo ) , pinfo , rtpinfo ) ;
rtp_packet_save_payload ( & ( user_data - > reversed . saveinfo ) ,
& ( user_data - > reversed . statinfo ) , pinfo , rtpinfo ) ;
2003-09-24 07:48:12 +00:00
}
return 0 ;
}
2009-03-02 07:31:06 +00:00
/*
Replaced by using the strings instead .
2004-01-24 01:15:24 +00:00
static const GdkColor COLOR_DEFAULT = { 0 , 0xffff , 0xffff , 0xffff } ;
static const GdkColor COLOR_ERROR = { 0 , 0xffff , 0xbfff , 0xbfff } ;
static const GdkColor COLOR_WARNING = { 0 , 0xffff , 0xdfff , 0xbfff } ;
static const GdkColor COLOR_CN = { 0 , 0xbfff , 0xbfff , 0xffff } ;
2008-05-01 18:26:01 +00:00
static const GdkColor COLOR_FOREGROUND = { 0 , 0x0000 , 0x0000 , 0x0000 } ;
2009-03-02 07:31:06 +00:00
*/
2003-09-25 19:35:14 +00:00
/****************************************************************************/
2009-02-20 17:13:44 +00:00
/* adds statistics information from the packet to the list */
static int rtp_packet_add_info ( GtkWidget * list , user_data_t * user_data ,
2005-01-01 02:57:02 +00:00
tap_rtp_stat_t * statinfo , packet_info * pinfo ,
const struct _rtp_info * rtpinfo )
2003-09-25 19:35:14 +00:00
{
guint16 msecs ;
gchar timeStr [ 32 ] ;
struct tm * tm_tmp ;
time_t then ;
gchar status [ 40 ] ;
2009-02-20 17:13:44 +00:00
gchar color_str [ 14 ] ;
2005-08-24 21:31:56 +00:00
then = pinfo - > fd - > abs_ts . secs ;
msecs = ( guint16 ) ( pinfo - > fd - > abs_ts . nsecs / 1000000 ) ;
2003-09-25 19:35:14 +00:00
tm_tmp = localtime ( & then ) ;
2004-03-13 12:09:27 +00:00
g_snprintf ( timeStr , sizeof ( timeStr ) , " %02d/%02d/%04d %02d:%02d:%02d.%03d " ,
2003-09-25 19:35:14 +00:00
tm_tmp - > tm_mon + 1 ,
tm_tmp - > tm_mday ,
tm_tmp - > tm_year + 1900 ,
tm_tmp - > tm_hour ,
tm_tmp - > tm_min ,
tm_tmp - > tm_sec ,
msecs ) ;
2009-02-26 07:55:09 +00:00
/* Default to using black on white text if nothing below overrides it */
g_snprintf ( color_str , sizeof ( color_str ) , " #ffffffffffff " ) ;
2003-09-25 19:35:14 +00:00
if ( statinfo - > pt = = PT_CN ) {
2004-03-13 12:09:27 +00:00
g_snprintf ( status , sizeof ( status ) , " Comfort noise (PT=13, RFC 3389) " ) ;
2009-03-02 07:31:06 +00:00
/* color = COLOR_CN; */
2009-02-20 17:13:44 +00:00
g_snprintf ( color_str , sizeof ( color_str ) , " #bfffbfffffff " ) ;
2003-09-25 19:35:14 +00:00
}
else if ( statinfo - > pt = = PT_CN_OLD ) {
2004-03-13 12:09:27 +00:00
g_snprintf ( status , sizeof ( status ) , " Comfort noise (PT=19, reserved) " ) ;
2009-03-02 07:31:06 +00:00
/* color = COLOR_CN; */
2009-02-20 17:13:44 +00:00
g_snprintf ( color_str , sizeof ( color_str ) , " #bfffbfffffff " ) ;
2003-09-25 19:35:14 +00:00
}
else if ( statinfo - > flags & STAT_FLAG_WRONG_SEQ ) {
2004-03-13 12:09:27 +00:00
g_snprintf ( status , sizeof ( status ) , " Wrong sequence nr. " ) ;
2009-03-02 07:31:06 +00:00
/* color = COLOR_ERROR; */
2009-02-20 17:13:44 +00:00
g_snprintf ( color_str , sizeof ( color_str ) , " #ffffbfffbfff " ) ;
2004-01-24 01:15:24 +00:00
}
else if ( statinfo - > flags & STAT_FLAG_REG_PT_CHANGE ) {
2004-03-13 12:09:27 +00:00
g_snprintf ( status , sizeof ( status ) , " Payload changed to PT=%u " , statinfo - > pt ) ;
2009-03-02 07:31:06 +00:00
/* color = COLOR_WARNING; */
2009-02-20 17:13:44 +00:00
g_snprintf ( color_str , sizeof ( color_str ) , " #ffffdfffbfff " ) ;
2003-09-25 19:35:14 +00:00
}
2004-12-02 08:38:59 +00:00
else if ( statinfo - > flags & STAT_FLAG_WRONG_TIMESTAMP ) {
g_snprintf ( status , sizeof ( status ) , " Incorrect timestamp " ) ;
2009-03-02 07:31:06 +00:00
/* color = COLOR_WARNING; */
2009-02-20 17:13:44 +00:00
g_snprintf ( color_str , sizeof ( color_str ) , " #ffffdfffbfff " ) ;
2004-12-02 08:38:59 +00:00
}
2003-09-25 19:35:14 +00:00
else if ( ( statinfo - > flags & STAT_FLAG_PT_CHANGE )
& & ! ( statinfo - > flags & STAT_FLAG_FIRST )
2004-01-24 01:15:24 +00:00
& & ! ( statinfo - > flags & STAT_FLAG_PT_CN )
& & ( statinfo - > flags & STAT_FLAG_FOLLOW_PT_CN )
& & ! ( statinfo - > flags & STAT_FLAG_MARKER ) ) {
2004-03-13 12:09:27 +00:00
g_snprintf ( status , sizeof ( status ) , " Marker missing? " ) ;
2009-03-02 07:31:06 +00:00
/* color = COLOR_WARNING; */
2009-02-20 17:13:44 +00:00
g_snprintf ( color_str , sizeof ( color_str ) , " #ffffdfffbfff " ) ;
2003-09-25 19:35:14 +00:00
}
else {
2004-01-24 01:15:24 +00:00
if ( statinfo - > flags & STAT_FLAG_MARKER ) {
2009-03-02 07:31:06 +00:00
/* color = COLOR_WARNING; */
2009-02-20 17:13:44 +00:00
g_snprintf ( color_str , sizeof ( color_str ) , " #ffffdfffbfff " ) ;
2004-01-24 01:15:24 +00:00
}
2004-03-13 12:09:27 +00:00
g_snprintf ( status , sizeof ( status ) , OK_TEXT ) ;
2003-09-25 19:35:14 +00:00
}
/* is this the first packet we got in this direction? */
2003-10-31 19:45:16 +00:00
if ( statinfo - > flags & STAT_FLAG_FIRST ) {
2009-02-20 17:13:44 +00:00
add_to_list ( list , user_data ,
2003-09-25 19:35:14 +00:00
pinfo - > fd - > num , rtpinfo - > info_seq_num ,
0 ,
0 ,
2004-10-11 05:23:31 +00:00
statinfo - > bandwidth ,
2003-09-25 19:35:14 +00:00
status ,
rtpinfo - > info_marker_set ,
timeStr , pinfo - > fd - > pkt_len ,
2009-02-20 17:13:44 +00:00
color_str ,
statinfo - > flags ) ;
2003-09-25 19:35:14 +00:00
}
else {
2009-02-20 17:13:44 +00:00
add_to_list ( list , user_data ,
2003-09-25 19:35:14 +00:00
pinfo - > fd - > num , rtpinfo - > info_seq_num ,
2004-12-01 11:54:41 +00:00
statinfo - > delta * 1000 ,
2004-10-01 07:14:50 +00:00
statinfo - > jitter * 1000 ,
2004-10-11 05:23:31 +00:00
statinfo - > bandwidth ,
2003-09-25 19:35:14 +00:00
status ,
rtpinfo - > info_marker_set ,
timeStr , pinfo - > fd - > pkt_len ,
2009-02-20 17:13:44 +00:00
color_str ,
statinfo - > flags ) ;
2003-09-25 19:35:14 +00:00
}
return 0 ;
}
2007-05-17 18:41:07 +00:00
# define MAX_SILENCE_TICKS 1000000
2003-09-25 19:35:14 +00:00
/****************************************************************************/
2007-05-17 18:41:07 +00:00
static int rtp_packet_save_payload ( tap_rtp_save_info_t * saveinfo ,
2005-01-01 02:57:02 +00:00
tap_rtp_stat_t * statinfo ,
packet_info * pinfo ,
const struct _rtp_info * rtpinfo )
2003-09-25 19:35:14 +00:00
{
guint i ;
2004-01-31 09:48:26 +00:00
const guint8 * data ;
2005-10-29 15:34:16 +00:00
guint8 tmp ;
2007-05-02 11:50:54 +00:00
size_t nchars ;
2003-09-25 19:35:14 +00:00
/* is this the first packet we got in this direction? */
2003-10-31 19:45:16 +00:00
if ( statinfo - > flags & STAT_FLAG_FIRST ) {
2003-09-25 19:35:14 +00:00
if ( saveinfo - > fp = = NULL ) {
saveinfo - > saved = FALSE ;
saveinfo - > error_type = TAP_RTP_FILE_OPEN_ERROR ;
}
else
saveinfo - > saved = TRUE ;
}
2003-09-24 07:48:12 +00:00
/* save the voice information */
/* if there was already an error, we quit */
2003-09-25 19:35:14 +00:00
if ( saveinfo - > saved = = FALSE )
2003-09-24 07:48:12 +00:00
return 0 ;
/* if the captured length and packet length aren't equal, we quit
2007-11-27 06:49:48 +00:00
* if also the RTP dissector thinks there is some information missing */
if ( ( pinfo - > fd - > pkt_len ! = pinfo - > fd - > cap_len ) & &
( ! rtpinfo - > info_all_data_present ) ) {
2003-09-25 19:35:14 +00:00
saveinfo - > saved = FALSE ;
saveinfo - > error_type = TAP_RTP_WRONG_LENGTH ;
2003-09-24 07:48:12 +00:00
return 0 ;
}
/* if padding bit is set, but the padding count is bigger
* then the whole RTP data - error with padding count */
2003-09-25 19:35:14 +00:00
if ( ( rtpinfo - > info_padding_set ! = FALSE ) & &
( rtpinfo - > info_padding_count > rtpinfo - > info_payload_len ) ) {
saveinfo - > saved = FALSE ;
saveinfo - > error_type = TAP_RTP_PADDING_ERROR ;
2003-09-24 07:48:12 +00:00
return 0 ;
}
/* do we need to insert some silence? */
2003-09-25 19:35:14 +00:00
if ( ( rtpinfo - > info_marker_set ) & &
2003-10-31 19:45:16 +00:00
! ( statinfo - > flags & STAT_FLAG_FIRST ) & &
2007-05-17 18:41:07 +00:00
! ( statinfo - > flags & STAT_FLAG_WRONG_TIMESTAMP ) & &
2003-09-25 19:35:14 +00:00
( statinfo - > delta_timestamp > ( rtpinfo - > info_payload_len - rtpinfo - > info_padding_count ) ) ) {
2003-09-24 07:48:12 +00:00
/* the amount of silence should be the difference between
* the last timestamp and the current one minus x
* x should equal the amount of information in the last frame
* XXX not done yet */
2003-09-25 19:35:14 +00:00
for ( i = 0 ; i < ( statinfo - > delta_timestamp - rtpinfo - > info_payload_len -
2007-05-17 18:41:07 +00:00
rtpinfo - > info_padding_count ) & & i < MAX_SILENCE_TICKS ; i + + ) {
2005-10-29 15:34:16 +00:00
switch ( statinfo - > reg_pt ) {
case PT_PCMU :
tmp = SILENCE_PCMU ;
break ;
case PT_PCMA :
tmp = SILENCE_PCMA ;
break ;
default :
tmp = 0 ;
break ;
}
2007-05-02 11:50:54 +00:00
nchars = fwrite ( & tmp , 1 , 1 , saveinfo - > fp ) ;
2003-09-25 19:35:14 +00:00
saveinfo - > count + + ;
2003-09-24 07:48:12 +00:00
}
2003-09-25 19:35:14 +00:00
fflush ( saveinfo - > fp ) ;
2003-09-24 07:48:12 +00:00
}
2007-05-17 18:41:07 +00:00
2005-09-01 05:41:59 +00:00
if ( rtpinfo - > info_payload_type = = PT_CN
| | rtpinfo - > info_payload_type = = PT_CN_OLD ) {
2003-09-24 07:48:12 +00:00
}
2005-09-01 05:41:59 +00:00
/*all other payloads*/
else {
2004-01-31 09:48:26 +00:00
if ( ! rtpinfo - > info_all_data_present ) {
/* Not all the data was captured. */
saveinfo - > saved = FALSE ;
saveinfo - > error_type = TAP_RTP_SHORT_FRAME ;
return 0 ;
}
/* we put the pointer at the beginning of the RTP
* payload , that is , at the beginning of the RTP data
* plus the offset of the payload from the beginning
* of the RTP data */
data = rtpinfo - > info_data + rtpinfo - > info_payload_offset ;
2007-05-02 11:50:54 +00:00
nchars = fwrite ( data , sizeof ( unsigned char ) , ( rtpinfo - > info_payload_len - rtpinfo - > info_padding_count ) , saveinfo - > fp ) ;
2005-09-01 05:41:59 +00:00
saveinfo - > count + = ( rtpinfo - > info_payload_len - rtpinfo - > info_padding_count ) ;
2003-09-25 19:35:14 +00:00
fflush ( saveinfo - > fp ) ;
saveinfo - > saved = TRUE ;
2003-09-24 07:48:12 +00:00
return 0 ;
}
2003-09-25 19:35:14 +00:00
2003-09-24 07:48:12 +00:00
return 0 ;
}
/****************************************************************************/
/* CALLBACKS */
/****************************************************************************/
/****************************************************************************/
/* close the dialog window and remove the tap listener */
static void on_destroy ( GtkWidget * win _U_ , user_data_t * user_data _U_ )
{
2004-10-01 07:14:50 +00:00
/* remove tap listener */
protect_thread_critical_region ( ) ;
remove_tap_listener ( user_data ) ;
unprotect_thread_critical_region ( ) ;
2004-01-23 00:29:52 +00:00
/* close and remove temporary files */
2003-09-25 19:35:14 +00:00
if ( user_data - > forward . saveinfo . fp ! = NULL )
fclose ( user_data - > forward . saveinfo . fp ) ;
if ( user_data - > reversed . saveinfo . fp ! = NULL )
fclose ( user_data - > reversed . saveinfo . fp ) ;
2004-01-27 18:05:32 +00:00
/*XXX: test for error **/
2008-05-22 15:46:27 +00:00
ws_remove ( user_data - > f_tempname ) ;
ws_remove ( user_data - > r_tempname ) ;
2003-09-24 07:48:12 +00:00
2004-01-23 00:29:52 +00:00
/* destroy save_voice_as window if open */
2003-09-24 07:48:12 +00:00
if ( user_data - > dlg . save_voice_as_w ! = NULL )
2004-05-26 03:49:24 +00:00
window_destroy ( user_data - > dlg . save_voice_as_w ) ;
2003-09-24 07:48:12 +00:00
2004-10-01 07:14:50 +00:00
/* destroy graph window if open */
if ( user_data - > dlg . dialog_graph . window ! = NULL )
window_destroy ( user_data - > dlg . dialog_graph . window ) ;
2003-09-24 07:48:12 +00:00
# ifdef USE_CONVERSATION_GRAPH
2004-01-23 00:29:52 +00:00
/* destroy graph window if open */
2003-09-24 07:48:12 +00:00
if ( user_data - > dlg . graph_window ! = NULL )
2004-05-26 03:49:24 +00:00
window_destroy ( user_data - > dlg . graph_window ) ;
2003-09-24 07:48:12 +00:00
# endif
2006-10-17 01:29:55 +00:00
/* disable the "switch_page" signal in the dlg, otherwise will be called when the windows is destroy and cause an exception using GTK1*/
2008-06-29 15:51:43 +00:00
g_signal_handler_disconnect ( user_data - > dlg . notebook , user_data - > dlg . notebook_signal_id ) ;
2004-10-01 07:14:50 +00:00
2003-09-24 07:48:12 +00:00
g_free ( user_data ) ;
}
2003-09-25 19:35:14 +00:00
/****************************************************************************/
static void on_notebook_switch_page ( GtkNotebook * notebook _U_ ,
GtkNotebookPage * page _U_ ,
gint page_num _U_ ,
user_data_t * user_data _U_ )
{
2009-02-20 17:13:44 +00:00
user_data - > dlg . selected_list =
( page_num = = 0 ) ? user_data - > dlg . list_fwd : user_data - > dlg . list_rev ;
user_data - > dlg . selected_list_row = 0 ;
2003-09-25 19:35:14 +00:00
}
2003-09-24 07:48:12 +00:00
/****************************************************************************/
2009-02-20 17:13:44 +00:00
static void on_list_select_row ( GtkTreeSelection * selection ,
user_data_t * user_data _U_ /*gpointer data */ )
2003-09-24 07:48:12 +00:00
{
2009-02-20 17:13:44 +00:00
user_data - > dlg . selected_list_sel = selection ;
2003-09-24 07:48:12 +00:00
}
# ifdef USE_CONVERSATION_GRAPH
2009-02-20 17:13:44 +00:00
Note this will not work any more as clist is removed .
2003-09-24 07:48:12 +00:00
/****************************************************************************/
/* when the graph window gets destroyed */
static void on_destroy_graph ( GtkWidget * win _U_ , user_data_t * user_data _U_ )
{
/* note that graph window has been destroyed */
user_data - > dlg . graph_window = NULL ;
}
/****************************************************************************/
static void graph_selection_callback ( value_pair_t vp , user_data_t * user_data )
{
guint row ;
GtkCList * clist = NULL ;
if ( vp . fnumber ! = 0 ) {
clist = GTK_CLIST ( user_data - > dlg . clist_fwd ) ;
row = gtk_clist_find_row_from_data ( clist ,
GUINT_TO_POINTER ( vp . fnumber ) ) ;
if ( row = = - 1 ) {
clist = GTK_CLIST ( user_data - > dlg . clist_rev ) ;
row = gtk_clist_find_row_from_data ( clist ,
GUINT_TO_POINTER ( vp . fnumber ) ) ;
}
if ( row ! = - 1 ) {
2008-06-29 15:51:43 +00:00
gtk_notebook_set_current_page ( GTK_NOTEBOOK ( user_data - > dlg . notebook ) ,
2003-09-24 07:48:12 +00:00
( clist = = GTK_CLIST ( user_data - > dlg . clist_fwd ) ) ? 0 : 1 ) ;
gtk_clist_select_row ( clist , row , 0 ) ;
gtk_clist_moveto ( clist , row , 0 , 0.5 , 0 ) ;
}
}
}
/****************************************************************************/
static void on_graph_bt_clicked ( GtkWidget * bt _U_ , user_data_t * user_data _U_ )
{
gchar title1 [ 80 ] ;
gchar title2 [ 80 ] ;
GList * list = NULL ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
if ( user_data - > dlg . graph_window ! = NULL ) {
/* There's already a graph window; reactivate it. */
reactivate_window ( user_data - > dlg . graph_window ) ;
return ;
}
list = g_list_append ( list , & ( user_data - > series_fwd ) ) ;
list = g_list_append ( list , & ( user_data - > series_rev ) ) ;
user_data - > series_fwd . color . pixel = 0 ;
user_data - > series_fwd . color . red = 0x80ff ;
user_data - > series_fwd . color . green = 0xe0ff ;
user_data - > series_fwd . color . blue = 0xffff ;
user_data - > series_fwd . yvalue = 0.5 ;
user_data - > series_rev . color . pixel = 0 ;
user_data - > series_rev . color . red = 0x60ff ;
user_data - > series_rev . color . green = 0xc0ff ;
user_data - > series_rev . color . blue = 0xffff ;
user_data - > series_rev . yvalue = - 0.5 ;
2007-05-31 18:41:25 +00:00
g_snprintf ( title1 , 80 , " Forward: %s:%u to %s:%u (SSRC=0x%X) " ,
2007-05-17 18:41:07 +00:00
get_addr_name ( & ( user_data - > ip_src_fwd ) ) ,
2003-09-24 07:48:12 +00:00
user_data - > port_src_fwd ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_dst_fwd ) ) ,
2003-09-24 07:48:12 +00:00
user_data - > port_dst_fwd ,
user_data - > ssrc_fwd ) ;
2007-05-31 18:41:25 +00:00
g_snprintf ( title2 , 80 , " Reverse: %s:%u to %s:%u (SSRC=0x%X) " ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_src_rev ) ) ,
2003-09-24 07:48:12 +00:00
user_data - > port_src_rev ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_dst_rev ) ) ,
2003-09-24 07:48:12 +00:00
user_data - > port_dst_rev ,
user_data - > ssrc_rev ) ;
user_data - > dlg . graph_window = show_conversation_graph ( list , title1 , title2 ,
& graph_selection_callback , user_data ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( user_data - > dlg . graph_window , " destroy " ,
G_CALLBACK ( on_destroy_graph ) , user_data ) ;
2003-09-24 07:48:12 +00:00
}
# endif /*USE_CONVERSATION_GRAPH*/
2004-10-01 07:14:50 +00:00
/****************************************************************************/
static void dialog_graph_set_title ( user_data_t * user_data )
{
char * title ;
if ( ! user_data - > dlg . dialog_graph . window ) {
return ;
}
title = g_strdup_printf ( " RTP Graph Analysis Forward: %s:%u to %s:%u Reverse: %s:%u to %s:%u " ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_src_fwd ) ) ,
2004-10-01 07:14:50 +00:00
user_data - > port_src_fwd ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_dst_fwd ) ) ,
2004-10-01 07:14:50 +00:00
user_data - > port_dst_fwd ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_src_rev ) ) ,
2004-10-01 07:14:50 +00:00
user_data - > port_src_rev ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_dst_rev ) ) ,
2004-10-01 07:14:50 +00:00
user_data - > port_dst_rev ) ;
gtk_window_set_title ( GTK_WINDOW ( user_data - > dlg . dialog_graph . window ) , title ) ;
2007-05-17 18:41:07 +00:00
g_free ( title ) ;
2004-10-01 07:14:50 +00:00
}
/****************************************************************************/
static void dialog_graph_reset ( user_data_t * user_data )
{
int i , j ;
user_data - > dlg . dialog_graph . needs_redraw = TRUE ;
for ( i = 0 ; i < MAX_GRAPHS ; i + + ) {
for ( j = 0 ; j < NUM_GRAPH_ITEMS ; j + + ) {
dialog_graph_graph_item_t * dggi ;
dggi = & user_data - > dlg . dialog_graph . graph [ i ] . items [ j ] ;
dggi - > value = 0 ;
dggi - > flags = 0 ;
}
}
user_data - > dlg . dialog_graph . last_interval = 0xffffffff ;
user_data - > dlg . dialog_graph . max_interval = 0 ;
user_data - > dlg . dialog_graph . num_items = 0 ;
/* create the color titles near the filter buttons */
for ( i = 0 ; i < MAX_GRAPHS ; i + + ) {
2007-05-17 18:41:07 +00:00
/* it is forward */
2004-10-01 07:14:50 +00:00
if ( i < 2 ) {
2007-05-31 18:41:25 +00:00
g_snprintf ( user_data - > dlg . dialog_graph . graph [ i ] . title , 100 , " %s: %s:%u to %s:%u (SSRC=0x%X) " ,
2009-02-20 17:13:44 +00:00
graph_descr [ i ] ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_src_fwd ) ) ,
2004-10-01 07:14:50 +00:00
user_data - > port_src_fwd ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_dst_fwd ) ) ,
2004-10-01 07:14:50 +00:00
user_data - > port_dst_fwd ,
user_data - > ssrc_fwd ) ;
/* it is reverse */
} else {
2007-05-31 18:41:25 +00:00
g_snprintf ( user_data - > dlg . dialog_graph . graph [ i ] . title , 100 , " %s: %s:%u to %s:%u (SSRC=0x%X) " ,
2009-02-20 17:13:44 +00:00
graph_descr [ i ] ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_src_rev ) ) ,
2004-10-01 07:14:50 +00:00
user_data - > port_src_rev ,
2005-03-02 23:22:11 +00:00
get_addr_name ( & ( user_data - > ip_dst_rev ) ) ,
2004-10-01 07:14:50 +00:00
user_data - > port_dst_rev ,
user_data - > ssrc_rev ) ;
}
}
2007-05-17 18:41:07 +00:00
dialog_graph_set_title ( user_data ) ;
2004-10-01 07:14:50 +00:00
}
/****************************************************************************/
static guint32 get_it_value ( dialog_graph_graph_t * dgg , int idx )
{
dialog_graph_graph_item_t * it ;
it = & dgg - > items [ idx ] ;
return it - > value ;
}
/****************************************************************************/
static void print_time_scale_string ( char * buf , int buf_len , guint32 t )
{
if ( t > = 10000000 ) {
g_snprintf ( buf , buf_len , " %ds " , t / 1000000 ) ;
} else if ( t > = 1000000 ) {
g_snprintf ( buf , buf_len , " %d.%03ds " , t / 1000000 , ( t % 1000000 ) / 1000 ) ;
} else if ( t > = 10000 ) {
g_snprintf ( buf , buf_len , " %dms " , t / 1000 ) ;
} else if ( t > = 1000 ) {
g_snprintf ( buf , buf_len , " %d.%03dms " , t / 1000 , t % 1000 ) ;
} else {
g_snprintf ( buf , buf_len , " %dus " , t ) ;
}
}
/****************************************************************************/
static void dialog_graph_draw ( user_data_t * user_data )
{
int i , lwidth ;
guint32 last_interval , first_interval , interval_delta , delta_multiplier ;
gint32 current_interval ;
guint32 left_x_border ;
guint32 right_x_border ;
guint32 top_y_border ;
guint32 bottom_y_border ;
PangoLayout * layout ;
2007-03-24 00:45:11 +00:00
int label_width , label_height ;
2004-10-01 07:14:50 +00:00
guint32 draw_width , draw_height ;
char label_string [ 15 ] ;
/* new variables */
guint32 num_time_intervals ;
guint32 max_value ; /* max value of seen data */
guint32 max_y ; /* max value of the Y scale */
if ( ! user_data - > dlg . dialog_graph . needs_redraw ) {
return ;
}
user_data - > dlg . dialog_graph . needs_redraw = FALSE ;
/*
* Find the length of the intervals we have data for
* so we know how large arrays we need to malloc ( )
*/
num_time_intervals = user_data - > dlg . dialog_graph . num_items ;
/* if there isnt anything to do, just return */
if ( num_time_intervals = = 0 ) {
return ;
}
num_time_intervals + = 1 ;
/* XXX move this check to _packet() */
if ( num_time_intervals > NUM_GRAPH_ITEMS ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " RTP Graph error. There are too many entries, bailing out " ) ;
return ;
}
/*
* find the max value so we can autoscale the y axis
*/
max_value = 0 ;
for ( i = 0 ; i < MAX_GRAPHS ; i + + ) {
int idx ;
if ( ! user_data - > dlg . dialog_graph . graph [ i ] . display ) {
continue ;
}
for ( idx = 0 ; ( guint32 ) ( idx ) < num_time_intervals ; idx + + ) {
guint32 val ;
val = get_it_value ( & user_data - > dlg . dialog_graph . graph [ i ] , idx ) ;
/* keep track of the max value we have encountered */
if ( val > max_value ) {
max_value = val ;
}
}
}
2007-05-17 18:41:07 +00:00
2004-10-01 07:14:50 +00:00
/*
* Clear out old plot
*/
gdk_draw_rectangle ( user_data - > dlg . dialog_graph . pixmap ,
user_data - > dlg . dialog_graph . draw_area - > style - > white_gc ,
TRUE ,
0 , 0 ,
user_data - > dlg . dialog_graph . draw_area - > allocation . width ,
user_data - > dlg . dialog_graph . draw_area - > allocation . height ) ;
/*
* Calculate the y scale we should use
*/
if ( user_data - > dlg . dialog_graph . max_y_units = = AUTO_MAX_YSCALE ) {
max_y = yscale_max [ MAX_YSCALE - 1 ] ;
for ( i = MAX_YSCALE - 1 ; i > 0 ; i - - ) {
if ( max_value < yscale_max [ i ] ) {
max_y = yscale_max [ i ] ;
}
}
} else {
/* the user had specified an explicit y scale to use */
max_y = user_data - > dlg . dialog_graph . max_y_units ;
}
/*
* Calculate size of borders surrounding the plot
* The border on the right side needs to be adjusted depending
* on the width of the text labels . For simplicity we assume that the
* top y scale label will be the widest one
*/
print_time_scale_string ( label_string , 15 , max_y ) ;
layout = gtk_widget_create_pango_layout ( user_data - > dlg . dialog_graph . draw_area , label_string ) ;
pango_layout_get_pixel_size ( layout , & label_width , & label_height ) ;
left_x_border = 10 ;
right_x_border = label_width + 20 ;
top_y_border = 10 ;
bottom_y_border = label_height + 20 ;
/*
* Calculate the size of the drawing area for the actual plot
*/
draw_width = user_data - > dlg . dialog_graph . pixmap_width - right_x_border - left_x_border ;
draw_height = user_data - > dlg . dialog_graph . pixmap_height - top_y_border - bottom_y_border ;
/*
* Draw the y axis and labels
* ( we always draw the y scale with 11 ticks along the axis )
*/
gdk_draw_line ( user_data - > dlg . dialog_graph . pixmap , user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 1 ,
top_y_border ,
user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 1 ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border ) ;
for ( i = 0 ; i < = 10 ; i + + ) {
int xwidth , lwidth ;
xwidth = 5 ;
if ( ! ( i % 5 ) ) {
/* first, middle and last tick are slightly longer */
xwidth = 10 ;
}
/* draw the tick */
gdk_draw_line ( user_data - > dlg . dialog_graph . pixmap , user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 1 ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border - draw_height * i / 10 ,
user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 1 + xwidth ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border - draw_height * i / 10 ) ;
/* draw the labels */
if ( i = = 0 ) {
print_time_scale_string ( label_string , 15 , ( max_y * i / 10 ) ) ;
pango_layout_set_text ( layout , label_string , - 1 ) ;
pango_layout_get_pixel_size ( layout , & lwidth , NULL ) ;
gdk_draw_layout ( user_data - > dlg . dialog_graph . pixmap ,
user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 15 + label_width - lwidth ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border - draw_height * i / 10 - label_height / 2 ,
layout ) ;
}
if ( i = = 5 ) {
print_time_scale_string ( label_string , 15 , ( max_y * i / 10 ) ) ;
pango_layout_set_text ( layout , label_string , - 1 ) ;
pango_layout_get_pixel_size ( layout , & lwidth , NULL ) ;
gdk_draw_layout ( user_data - > dlg . dialog_graph . pixmap ,
user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 15 + label_width - lwidth ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border - draw_height * i / 10 - label_height / 2 ,
layout ) ;
}
if ( i = = 10 ) {
print_time_scale_string ( label_string , 15 , ( max_y * i / 10 ) ) ;
pango_layout_set_text ( layout , label_string , - 1 ) ;
pango_layout_get_pixel_size ( layout , & lwidth , NULL ) ;
gdk_draw_layout ( user_data - > dlg . dialog_graph . pixmap ,
user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 15 + label_width - lwidth ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border - draw_height * i / 10 - label_height / 2 ,
layout ) ;
}
}
/*
* if we have not specified the last_interval via the gui ,
* then just pick the current end of the capture so that is scrolls
* nicely when doing live captures
*/
if ( user_data - > dlg . dialog_graph . last_interval = = 0xffffffff ) {
last_interval = user_data - > dlg . dialog_graph . max_interval ;
} else {
last_interval = user_data - > dlg . dialog_graph . last_interval ;
}
/*XXX*/
/* plot the x-scale */
gdk_draw_line ( user_data - > dlg . dialog_graph . pixmap , user_data - > dlg . dialog_graph . draw_area - > style - > black_gc , left_x_border , user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border + 1 , user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 1 , user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border + 1 ) ;
if ( ( last_interval / user_data - > dlg . dialog_graph . interval ) > draw_width / user_data - > dlg . dialog_graph . pixels_per_tick + 1 ) {
first_interval = ( last_interval / user_data - > dlg . dialog_graph . interval ) - draw_width / user_data - > dlg . dialog_graph . pixels_per_tick + 1 ;
first_interval * = user_data - > dlg . dialog_graph . interval ;
} else {
first_interval = 0 ;
}
interval_delta = 1 ;
delta_multiplier = 5 ;
while ( interval_delta < ( ( last_interval - first_interval ) / 10 ) ) {
interval_delta * = delta_multiplier ;
if ( delta_multiplier = = 5 ) {
delta_multiplier = 2 ;
} else {
delta_multiplier = 5 ;
}
}
for ( current_interval = last_interval ; current_interval > ( gint32 ) first_interval ; current_interval = current_interval - user_data - > dlg . dialog_graph . interval ) {
int x , xlen ;
/* if pixels_per_tick is <5, only draw every 10 ticks */
if ( ( user_data - > dlg . dialog_graph . pixels_per_tick < 10 ) & & ( current_interval % ( 10 * user_data - > dlg . dialog_graph . interval ) ) ) {
continue ;
}
if ( current_interval % interval_delta ) {
xlen = 5 ;
} else {
xlen = 17 ;
}
x = draw_width + left_x_border - ( ( last_interval - current_interval ) / user_data - > dlg . dialog_graph . interval ) * user_data - > dlg . dialog_graph . pixels_per_tick ;
gdk_draw_line ( user_data - > dlg . dialog_graph . pixmap , user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
x - 1 - user_data - > dlg . dialog_graph . pixels_per_tick / 2 ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border + 1 ,
x - 1 - user_data - > dlg . dialog_graph . pixels_per_tick / 2 ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border + xlen + 1 ) ;
if ( xlen = = 17 ) {
int lwidth ;
if ( user_data - > dlg . dialog_graph . interval > = 1000 ) {
g_snprintf ( label_string , 15 , " %ds " , current_interval / 1000 ) ;
} else if ( user_data - > dlg . dialog_graph . interval > = 100 ) {
2009-02-20 17:13:44 +00:00
g_snprintf ( label_string , 15 , " %d.%1ds " , current_interval / 1000 , ( current_interval / 100 ) % 10 ) ;
2004-10-01 07:14:50 +00:00
} else if ( user_data - > dlg . dialog_graph . interval > = 10 ) {
2009-02-20 17:13:44 +00:00
g_snprintf ( label_string , 15 , " %d.%2ds " , current_interval / 1000 , ( current_interval / 10 ) % 100 ) ;
2004-10-01 07:14:50 +00:00
} else {
g_snprintf ( label_string , 15 , " %d.%3ds " , current_interval / 1000 , current_interval % 1000 ) ;
}
pango_layout_set_text ( layout , label_string , - 1 ) ;
pango_layout_get_pixel_size ( layout , & lwidth , NULL ) ;
gdk_draw_layout ( user_data - > dlg . dialog_graph . pixmap ,
user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
x - 1 - user_data - > dlg . dialog_graph . pixels_per_tick / 2 - lwidth / 2 ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border + 20 ,
layout ) ;
}
}
/*
* Draw " x " for Sequence Errors and " m " for Marks
*/
/* Draw the labels Fwd and Rev */
2008-02-29 13:33:37 +00:00
g_strlcpy ( label_string , " <-Fwd " , 15 ) ;
2004-10-01 07:14:50 +00:00
pango_layout_set_text ( layout , label_string , - 1 ) ;
pango_layout_get_pixel_size ( layout , & lwidth , NULL ) ;
gdk_draw_layout ( user_data - > dlg . dialog_graph . pixmap ,
user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 33 - lwidth ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border + 3 ,
layout ) ;
2008-02-29 13:33:37 +00:00
g_strlcpy ( label_string , " <-Rev " , 15 ) ;
2004-10-01 07:14:50 +00:00
pango_layout_set_text ( layout , label_string , - 1 ) ;
pango_layout_get_pixel_size ( layout , & lwidth , NULL ) ;
gdk_draw_layout ( user_data - > dlg . dialog_graph . pixmap ,
user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
user_data - > dlg . dialog_graph . pixmap_width - right_x_border + 33 - lwidth ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border + 3 + 9 ,
layout ) ;
2007-05-17 18:41:07 +00:00
/* Draw the marks */
2004-10-01 07:14:50 +00:00
for ( i = MAX_GRAPHS - 1 ; i > = 0 ; i - - ) {
guint32 interval ;
guint32 x_pos , prev_x_pos ;
/* XXX for fwd or rev, the flag info for jitter and diff is the same, and here I loop twice */
if ( ! user_data - > dlg . dialog_graph . graph [ i ] . display ) {
continue ;
}
/* initialize prev x/y to the low left corner of the graph */
prev_x_pos = draw_width - 1 - user_data - > dlg . dialog_graph . pixels_per_tick * ( ( last_interval - first_interval ) / user_data - > dlg . dialog_graph . interval + 1 ) + left_x_border ;
for ( interval = first_interval + user_data - > dlg . dialog_graph . interval ; interval < = last_interval ; interval + = user_data - > dlg . dialog_graph . interval ) {
x_pos = draw_width - 1 - user_data - > dlg . dialog_graph . pixels_per_tick * ( ( last_interval - interval ) / user_data - > dlg . dialog_graph . interval + 1 ) + left_x_border ;
if ( user_data - > dlg . dialog_graph . graph [ i ] . items [ interval / user_data - > dlg . dialog_graph . interval ] . flags & ( STAT_FLAG_WRONG_SEQ | STAT_FLAG_MARKER ) ) {
int lwidth ;
if ( user_data - > dlg . dialog_graph . graph [ i ] . items [ interval / user_data - > dlg . dialog_graph . interval ] . flags & STAT_FLAG_WRONG_SEQ ) {
2008-02-29 13:33:37 +00:00
g_strlcpy ( label_string , " x " , 15 ) ;
2004-10-01 07:14:50 +00:00
} else {
2008-02-29 13:33:37 +00:00
g_strlcpy ( label_string , " m " , 15 ) ;
2004-10-01 07:14:50 +00:00
}
2007-05-17 18:41:07 +00:00
2004-10-01 07:14:50 +00:00
pango_layout_set_text ( layout , label_string , - 1 ) ;
pango_layout_get_pixel_size ( layout , & lwidth , NULL ) ;
gdk_draw_layout ( user_data - > dlg . dialog_graph . pixmap ,
user_data - > dlg . dialog_graph . draw_area - > style - > black_gc ,
x_pos - 1 - lwidth / 2 ,
user_data - > dlg . dialog_graph . pixmap_height - bottom_y_border + 3 + 7 * ( i / 2 ) ,
layout ) ;
}
prev_x_pos = x_pos ;
}
}
g_object_unref ( G_OBJECT ( layout ) ) ;
/*
* Loop over all graphs and draw them
*/
for ( i = MAX_GRAPHS - 1 ; i > = 0 ; i - - ) {
guint32 interval ;
guint32 x_pos , y_pos , prev_x_pos , prev_y_pos ;
if ( ! user_data - > dlg . dialog_graph . graph [ i ] . display ) {
continue ;
2007-05-17 18:41:07 +00:00
}
2004-10-01 07:14:50 +00:00
/* initialize prev x/y to the low left corner of the graph */
prev_x_pos = draw_width - 1 - user_data - > dlg . dialog_graph . pixels_per_tick * ( ( last_interval - first_interval ) / user_data - > dlg . dialog_graph . interval + 1 ) + left_x_border ;
prev_y_pos = draw_height - 1 + top_y_border ;
2007-05-17 18:41:07 +00:00
2004-10-01 07:14:50 +00:00
for ( interval = first_interval + user_data - > dlg . dialog_graph . interval ; interval < = last_interval ; interval + = user_data - > dlg . dialog_graph . interval ) {
guint32 val ;
x_pos = draw_width - 1 - user_data - > dlg . dialog_graph . pixels_per_tick * ( ( last_interval - interval ) / user_data - > dlg . dialog_graph . interval + 1 ) + left_x_border ;
val = get_it_value ( & user_data - > dlg . dialog_graph . graph [ i ] , interval / user_data - > dlg . dialog_graph . interval ) ;
if ( val > max_y ) {
y_pos = 0 ;
} else {
y_pos = draw_height - 1 - ( val * draw_height ) / max_y + top_y_border ;
}
/* dont need to draw anything if the segment
* is entirely above the top of the graph
*/
if ( ( prev_y_pos = = 0 ) & & ( y_pos = = 0 ) ) {
prev_y_pos = y_pos ;
prev_x_pos = x_pos ;
continue ;
}
2007-05-17 18:41:07 +00:00
2004-10-01 07:14:50 +00:00
if ( val ) {
gdk_draw_line ( user_data - > dlg . dialog_graph . pixmap , user_data - > dlg . dialog_graph . graph [ i ] . gc ,
x_pos , draw_height - 1 + top_y_border ,
x_pos , y_pos ) ;
}
prev_y_pos = y_pos ;
prev_x_pos = x_pos ;
}
}
gdk_draw_pixmap ( user_data - > dlg . dialog_graph . draw_area - > window ,
user_data - > dlg . dialog_graph . draw_area - > style - > fg_gc [ GTK_WIDGET_STATE ( user_data - > dlg . dialog_graph . draw_area ) ] ,
user_data - > dlg . dialog_graph . pixmap ,
0 , 0 ,
0 , 0 ,
user_data - > dlg . dialog_graph . pixmap_width , user_data - > dlg . dialog_graph . pixmap_height ) ;
/* update the scrollbar */
user_data - > dlg . dialog_graph . scrollbar_adjustment - > upper = ( gfloat ) user_data - > dlg . dialog_graph . max_interval ;
user_data - > dlg . dialog_graph . scrollbar_adjustment - > step_increment = ( gfloat ) ( ( last_interval - first_interval ) / 10 ) ;
user_data - > dlg . dialog_graph . scrollbar_adjustment - > page_increment = ( gfloat ) ( last_interval - first_interval ) ;
if ( ( last_interval - first_interval ) * 100 < user_data - > dlg . dialog_graph . max_interval ) {
user_data - > dlg . dialog_graph . scrollbar_adjustment - > page_size = ( gfloat ) ( user_data - > dlg . dialog_graph . max_interval / 100 ) ;
} else {
user_data - > dlg . dialog_graph . scrollbar_adjustment - > page_size = ( gfloat ) ( last_interval - first_interval ) ;
}
user_data - > dlg . dialog_graph . scrollbar_adjustment - > value = last_interval - user_data - > dlg . dialog_graph . scrollbar_adjustment - > page_size ;
gtk_adjustment_changed ( user_data - > dlg . dialog_graph . scrollbar_adjustment ) ;
gtk_adjustment_value_changed ( user_data - > dlg . dialog_graph . scrollbar_adjustment ) ;
}
/****************************************************************************/
static void dialog_graph_redraw ( user_data_t * user_data )
{
user_data - > dlg . dialog_graph . needs_redraw = TRUE ;
2007-05-17 18:41:07 +00:00
dialog_graph_draw ( user_data ) ;
2004-10-01 07:14:50 +00:00
}
/****************************************************************************/
static gint quit ( GtkWidget * widget , GdkEventExpose * event _U_ )
{
2009-02-20 17:13:44 +00:00
user_data_t * user_data ;
2004-10-01 07:14:50 +00:00
2009-02-20 17:13:44 +00:00
user_data = ( user_data_t * ) g_object_get_data ( G_OBJECT ( widget ) , " user_data_t " ) ;
2004-10-01 07:14:50 +00:00
user_data - > dlg . dialog_graph . window = NULL ;
2009-02-20 17:13:44 +00:00
return TRUE ;
2004-10-01 07:14:50 +00:00
}
/****************************************************************************/
static gint expose_event ( GtkWidget * widget , GdkEventExpose * event )
{
user_data_t * user_data ;
2008-04-11 16:04:54 +00:00
user_data = ( user_data_t * ) g_object_get_data ( G_OBJECT ( widget ) , " user_data_t " ) ;
2009-02-20 17:13:44 +00:00
if ( ! user_data ) {
exit ( 10 ) ;
}
2004-10-01 07:14:50 +00:00
gdk_draw_pixmap ( widget - > window ,
widget - > style - > fg_gc [ GTK_WIDGET_STATE ( widget ) ] ,
user_data - > dlg . dialog_graph . pixmap ,
event - > area . x , event - > area . y ,
event - > area . x , event - > area . y ,
event - > area . width , event - > area . height ) ;
return FALSE ;
}
/****************************************************************************/
static gint configure_event ( GtkWidget * widget , GdkEventConfigure * event _U_ )
{
user_data_t * user_data ;
int i ;
2008-04-11 16:04:54 +00:00
user_data = ( user_data_t * ) g_object_get_data ( G_OBJECT ( widget ) , " user_data_t " ) ;
2004-10-01 07:14:50 +00:00
if ( ! user_data ) {
exit ( 10 ) ;
}
if ( user_data - > dlg . dialog_graph . pixmap ) {
gdk_pixmap_unref ( user_data - > dlg . dialog_graph . pixmap ) ;
user_data - > dlg . dialog_graph . pixmap = NULL ;
}
user_data - > dlg . dialog_graph . pixmap = gdk_pixmap_new ( widget - > window ,
widget - > allocation . width ,
widget - > allocation . height ,
- 1 ) ;
user_data - > dlg . dialog_graph . pixmap_width = widget - > allocation . width ;
user_data - > dlg . dialog_graph . pixmap_height = widget - > allocation . height ;
gdk_draw_rectangle ( user_data - > dlg . dialog_graph . pixmap ,
widget - > style - > white_gc ,
TRUE ,
0 , 0 ,
widget - > allocation . width ,
widget - > allocation . height ) ;
/* set up the colors and the GC structs for this pixmap */
for ( i = 0 ; i < MAX_GRAPHS ; i + + ) {
user_data - > dlg . dialog_graph . graph [ i ] . gc = gdk_gc_new ( user_data - > dlg . dialog_graph . pixmap ) ;
gdk_gc_set_rgb_fg_color ( user_data - > dlg . dialog_graph . graph [ i ] . gc , & user_data - > dlg . dialog_graph . graph [ i ] . color ) ;
}
dialog_graph_redraw ( user_data ) ;
return TRUE ;
}
/****************************************************************************/
static gint scrollbar_changed ( GtkWidget * widget _U_ , gpointer data )
{
user_data_t * user_data = ( user_data_t * ) data ;
guint32 mi ;
mi = ( guint32 ) ( user_data - > dlg . dialog_graph . scrollbar_adjustment - > value + user_data - > dlg . dialog_graph . scrollbar_adjustment - > page_size ) ;
if ( user_data - > dlg . dialog_graph . last_interval = = mi ) {
return TRUE ;
}
if ( ( user_data - > dlg . dialog_graph . last_interval = = 0xffffffff )
& & ( mi = = user_data - > dlg . dialog_graph . max_interval ) ) {
return TRUE ;
}
user_data - > dlg . dialog_graph . last_interval = ( mi / user_data - > dlg . dialog_graph . interval ) * user_data - > dlg . dialog_graph . interval ;
dialog_graph_redraw ( user_data ) ;
return TRUE ;
}
/****************************************************************************/
static void create_draw_area ( user_data_t * user_data , GtkWidget * box )
{
user_data - > dlg . dialog_graph . draw_area = gtk_drawing_area_new ( ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( user_data - > dlg . dialog_graph . draw_area , " destroy " , G_CALLBACK ( quit ) , user_data ) ;
2008-04-11 16:04:54 +00:00
g_object_set_data ( G_OBJECT ( user_data - > dlg . dialog_graph . draw_area ) , " user_data_t " , user_data ) ;
2004-10-01 07:14:50 +00:00
2008-04-11 20:31:05 +00:00
gtk_widget_set_size_request ( user_data - > dlg . dialog_graph . draw_area , user_data - > dlg . dialog_graph . pixmap_width , user_data - > dlg . dialog_graph . pixmap_height ) ;
2004-10-01 07:14:50 +00:00
/* signals needed to handle backing pixmap */
2008-04-11 23:16:06 +00:00
g_signal_connect ( user_data - > dlg . dialog_graph . draw_area , " expose_event " , G_CALLBACK ( expose_event ) , NULL ) ;
g_signal_connect ( user_data - > dlg . dialog_graph . draw_area , " configure_event " , G_CALLBACK ( configure_event ) , user_data ) ;
2004-10-01 07:14:50 +00:00
gtk_widget_show ( user_data - > dlg . dialog_graph . draw_area ) ;
gtk_box_pack_start ( GTK_BOX ( box ) , user_data - > dlg . dialog_graph . draw_area , TRUE , TRUE , 0 ) ;
/* create the associated scrollbar */
user_data - > dlg . dialog_graph . scrollbar_adjustment = ( GtkAdjustment * ) gtk_adjustment_new ( 0 , 0 , 0 , 0 , 0 , 0 ) ;
user_data - > dlg . dialog_graph . scrollbar = gtk_hscrollbar_new ( user_data - > dlg . dialog_graph . scrollbar_adjustment ) ;
gtk_widget_show ( user_data - > dlg . dialog_graph . scrollbar ) ;
gtk_box_pack_start ( GTK_BOX ( box ) , user_data - > dlg . dialog_graph . scrollbar , FALSE , FALSE , 0 ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( user_data - > dlg . dialog_graph . scrollbar_adjustment , " value_changed " , G_CALLBACK ( scrollbar_changed ) , user_data ) ;
2004-10-01 07:14:50 +00:00
}
/****************************************************************************/
static void disable_graph ( dialog_graph_graph_t * dgg )
{
if ( dgg - > display ) {
dgg - > display = FALSE ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( dgg - > display_button ) ,
FALSE ) ;
}
}
/****************************************************************************/
static gint filter_callback ( GtkWidget * widget _U_ , dialog_graph_graph_t * dgg )
{
/* this graph is not active, just update display and redraw */
if ( ! gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( dgg - > display_button ) ) ) {
2007-05-17 18:41:07 +00:00
disable_graph ( dgg ) ;
2004-10-01 07:14:50 +00:00
dialog_graph_redraw ( dgg - > ud ) ;
return 0 ;
}
2009-02-20 17:13:44 +00:00
enable_graph ( dgg ) ;
2005-09-14 08:59:41 +00:00
cf_retap_packets ( & cfile , FALSE ) ;
2004-10-01 07:14:50 +00:00
dialog_graph_redraw ( dgg - > ud ) ;
return 0 ;
}
/****************************************************************************/
static void create_filter_box ( dialog_graph_graph_t * dgg , GtkWidget * box , int num )
{
GtkWidget * hbox ;
GtkWidget * label ;
char str [ 256 ] ;
hbox = gtk_hbox_new ( FALSE , 3 ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , hbox ) ;
gtk_box_set_child_packing ( GTK_BOX ( box ) , hbox , FALSE , FALSE , 0 , GTK_PACK_START ) ;
gtk_widget_show ( hbox ) ;
g_snprintf ( str , 256 , " Graph %d " , num ) ;
dgg - > display_button = gtk_toggle_button_new_with_label ( str ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , dgg - > display_button , FALSE , FALSE , 0 ) ;
gtk_widget_show ( dgg - > display_button ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( dgg - > display_button ) , dgg - > display ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( dgg - > display_button , " toggled " , G_CALLBACK ( filter_callback ) , dgg ) ;
2004-10-01 07:14:50 +00:00
label = gtk_label_new ( dgg - > title ) ;
gtk_widget_show ( label ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , label , FALSE , FALSE , 0 ) ;
gtk_widget_modify_fg ( label , GTK_STATE_NORMAL , & dgg - > color ) ;
gtk_widget_modify_fg ( label , GTK_STATE_ACTIVE , & dgg - > color ) ;
gtk_widget_modify_fg ( label , GTK_STATE_PRELIGHT , & dgg - > color ) ;
gtk_widget_modify_fg ( label , GTK_STATE_SELECTED , & dgg - > color ) ;
gtk_widget_modify_fg ( label , GTK_STATE_INSENSITIVE , & dgg - > color ) ;
return ;
}
/****************************************************************************/
static void create_filter_area ( user_data_t * user_data , GtkWidget * box )
{
GtkWidget * frame ;
GtkWidget * vbox ;
int i ;
GtkWidget * label ;
frame = gtk_frame_new ( " Graphs " ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , frame ) ;
gtk_widget_show ( frame ) ;
vbox = gtk_vbox_new ( FALSE , 1 ) ;
gtk_container_add ( GTK_CONTAINER ( frame ) , vbox ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( vbox ) , 3 ) ;
2004-10-01 07:14:50 +00:00
gtk_box_set_child_packing ( GTK_BOX ( box ) , vbox , FALSE , FALSE , 0 , GTK_PACK_START ) ;
gtk_widget_show ( vbox ) ;
for ( i = 0 ; i < MAX_GRAPHS ; i + + ) {
create_filter_box ( & user_data - > dlg . dialog_graph . graph [ i ] , vbox , i + 1 ) ;
}
label = gtk_label_new ( " Label: x = Wrong Seq. number m = Mark set " ) ;
gtk_widget_show ( label ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , label , FALSE , FALSE , 0 ) ;
return ;
}
/****************************************************************************/
static void yscale_select ( GtkWidget * item , gpointer key )
{
int val ;
user_data_t * user_data ;
2007-05-17 18:41:07 +00:00
2004-10-01 07:14:50 +00:00
user_data = ( user_data_t * ) key ;
2008-04-11 16:04:54 +00:00
val = ( long ) g_object_get_data ( G_OBJECT ( item ) , " yscale_max " ) ;
2004-10-01 07:14:50 +00:00
user_data - > dlg . dialog_graph . max_y_units = val ;
dialog_graph_redraw ( user_data ) ;
}
/****************************************************************************/
static void pixels_per_tick_select ( GtkWidget * item , gpointer key )
{
int val ;
user_data_t * user_data ;
user_data = ( user_data_t * ) key ;
2008-04-11 16:04:54 +00:00
val = ( long ) g_object_get_data ( G_OBJECT ( item ) , " pixels_per_tick " ) ;
2004-10-01 07:14:50 +00:00
user_data - > dlg . dialog_graph . pixels_per_tick = val ;
dialog_graph_redraw ( user_data ) ;
}
/****************************************************************************/
static void tick_interval_select ( GtkWidget * item , gpointer key )
{
int val ;
user_data_t * user_data ;
user_data = ( user_data_t * ) key ;
2008-04-11 16:04:54 +00:00
val = ( long ) g_object_get_data ( G_OBJECT ( item ) , " tick_interval " ) ;
2004-10-01 07:14:50 +00:00
user_data - > dlg . dialog_graph . interval = val ;
2005-09-14 08:59:41 +00:00
cf_retap_packets ( & cfile , FALSE ) ;
2004-10-01 07:14:50 +00:00
dialog_graph_redraw ( user_data ) ;
}
/****************************************************************************/
static void create_yscale_max_menu_items ( user_data_t * user_data , GtkWidget * menu )
{
char str [ 15 ] ;
GtkWidget * menu_item ;
int i ;
for ( i = 0 ; i < MAX_YSCALE ; i + + ) {
if ( yscale_max [ i ] = = AUTO_MAX_YSCALE ) {
2008-02-29 13:33:37 +00:00
g_strlcpy ( str , " Auto " , 15 ) ;
2004-10-01 07:14:50 +00:00
} else {
2005-01-01 23:54:32 +00:00
g_snprintf ( str , 15 , " %u ms " , yscale_max [ i ] / 1000 ) ;
2004-10-01 07:14:50 +00:00
}
menu_item = gtk_menu_item_new_with_label ( str ) ;
2008-04-11 16:04:54 +00:00
g_object_set_data ( G_OBJECT ( menu_item ) , " yscale_max " ,
2005-01-01 23:54:32 +00:00
GUINT_TO_POINTER ( yscale_max [ i ] ) ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( menu_item , " activate " , G_CALLBACK ( yscale_select ) , user_data ) ;
2004-10-01 07:14:50 +00:00
gtk_widget_show ( menu_item ) ;
2008-06-29 15:51:43 +00:00
gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ) , menu_item ) ;
2004-10-01 07:14:50 +00:00
}
return ;
}
/****************************************************************************/
static void create_pixels_per_tick_menu_items ( user_data_t * user_data , GtkWidget * menu )
{
char str [ 5 ] ;
GtkWidget * menu_item ;
int i ;
for ( i = 0 ; i < MAX_PIXELS_PER_TICK ; i + + ) {
2005-01-01 23:54:32 +00:00
g_snprintf ( str , 5 , " %u " , pixels_per_tick [ i ] ) ;
2004-10-01 07:14:50 +00:00
menu_item = gtk_menu_item_new_with_label ( str ) ;
2008-04-11 16:04:54 +00:00
g_object_set_data ( G_OBJECT ( menu_item ) , " pixels_per_tick " ,
2005-01-01 23:54:32 +00:00
GUINT_TO_POINTER ( pixels_per_tick [ i ] ) ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( menu_item , " activate " , G_CALLBACK ( pixels_per_tick_select ) , user_data ) ;
2004-10-01 07:14:50 +00:00
gtk_widget_show ( menu_item ) ;
2008-06-29 15:51:43 +00:00
gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ) , menu_item ) ;
2004-10-01 07:14:50 +00:00
}
gtk_menu_set_active ( GTK_MENU ( menu ) , DEFAULT_PIXELS_PER_TICK ) ;
return ;
}
/****************************************************************************/
static void create_tick_interval_menu_items ( user_data_t * user_data , GtkWidget * menu )
{
char str [ 15 ] ;
GtkWidget * menu_item ;
int i ;
for ( i = 0 ; i < MAX_TICK_VALUES ; i + + ) {
if ( tick_interval_values [ i ] > = 1000 ) {
2005-01-01 23:54:32 +00:00
g_snprintf ( str , 15 , " %u sec " , tick_interval_values [ i ] / 1000 ) ;
2004-10-01 07:14:50 +00:00
} else if ( tick_interval_values [ i ] > = 100 ) {
2005-01-01 23:54:32 +00:00
g_snprintf ( str , 15 , " 0.%1u sec " , ( tick_interval_values [ i ] / 100 ) % 10 ) ;
2004-10-01 07:14:50 +00:00
} else if ( tick_interval_values [ i ] > = 10 ) {
2005-01-01 23:54:32 +00:00
g_snprintf ( str , 15 , " 0.%02u sec " , ( tick_interval_values [ i ] / 10 ) % 10 ) ;
2004-10-01 07:14:50 +00:00
} else {
2005-01-01 23:54:32 +00:00
g_snprintf ( str , 15 , " 0.%03u sec " , ( tick_interval_values [ i ] ) % 10 ) ;
2004-10-01 07:14:50 +00:00
}
menu_item = gtk_menu_item_new_with_label ( str ) ;
2008-04-11 16:04:54 +00:00
g_object_set_data ( G_OBJECT ( menu_item ) , " tick_interval " ,
2005-01-01 23:54:32 +00:00
GUINT_TO_POINTER ( tick_interval_values [ i ] ) ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( menu_item , " activate " , G_CALLBACK ( tick_interval_select ) , ( gpointer ) user_data ) ;
2004-10-01 07:14:50 +00:00
gtk_widget_show ( menu_item ) ;
2008-06-29 15:51:43 +00:00
gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ) , menu_item ) ;
2004-10-01 07:14:50 +00:00
}
gtk_menu_set_active ( GTK_MENU ( menu ) , DEFAULT_TICK_VALUE ) ;
return ;
}
/****************************************************************************/
2005-08-06 14:03:14 +00:00
static void create_ctrl_menu ( user_data_t * user_data , GtkWidget * box , const char * name , void ( * func ) ( user_data_t * user_data , GtkWidget * menu ) )
2004-10-01 07:14:50 +00:00
{
GtkWidget * hbox ;
GtkWidget * label ;
GtkWidget * option_menu ;
GtkWidget * menu ;
hbox = gtk_hbox_new ( FALSE , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , hbox ) ;
gtk_box_set_child_packing ( GTK_BOX ( box ) , hbox , FALSE , FALSE , 0 , GTK_PACK_START ) ;
gtk_widget_show ( hbox ) ;
label = gtk_label_new ( name ) ;
gtk_widget_show ( label ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , label , FALSE , FALSE , 0 ) ;
option_menu = gtk_option_menu_new ( ) ;
menu = gtk_menu_new ( ) ;
( * func ) ( user_data , menu ) ;
gtk_option_menu_set_menu ( GTK_OPTION_MENU ( option_menu ) , menu ) ;
gtk_box_pack_end ( GTK_BOX ( hbox ) , option_menu , FALSE , FALSE , 0 ) ;
gtk_widget_show ( option_menu ) ;
}
/****************************************************************************/
static void create_ctrl_area ( user_data_t * user_data , GtkWidget * box )
{
GtkWidget * frame_vbox ;
GtkWidget * frame ;
GtkWidget * vbox ;
frame_vbox = gtk_vbox_new ( FALSE , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , frame_vbox ) ;
gtk_widget_show ( frame_vbox ) ;
frame = gtk_frame_new ( " X Axis " ) ;
gtk_container_add ( GTK_CONTAINER ( frame_vbox ) , frame ) ;
gtk_widget_show ( frame ) ;
vbox = gtk_vbox_new ( FALSE , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( frame ) , vbox ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( vbox ) , 3 ) ;
2004-10-01 07:14:50 +00:00
gtk_box_set_child_packing ( GTK_BOX ( box ) , vbox , FALSE , FALSE , 0 , GTK_PACK_END ) ;
gtk_widget_show ( vbox ) ;
create_ctrl_menu ( user_data , vbox , " Tick interval: " , create_tick_interval_menu_items ) ;
create_ctrl_menu ( user_data , vbox , " Pixels per tick: " , create_pixels_per_tick_menu_items ) ;
frame = gtk_frame_new ( " Y Axis " ) ;
gtk_container_add ( GTK_CONTAINER ( frame_vbox ) , frame ) ;
gtk_widget_show ( frame ) ;
vbox = gtk_vbox_new ( FALSE , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( frame ) , vbox ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( vbox ) , 3 ) ;
2004-10-01 07:14:50 +00:00
gtk_box_set_child_packing ( GTK_BOX ( box ) , vbox , FALSE , FALSE , 0 , GTK_PACK_END ) ;
gtk_widget_show ( vbox ) ;
create_ctrl_menu ( user_data , vbox , " Scale: " , create_yscale_max_menu_items ) ;
return ;
}
/****************************************************************************/
static void dialog_graph_init_window ( user_data_t * user_data )
{
GtkWidget * vbox ;
GtkWidget * hbox ;
GtkWidget * bt_close ;
/* create the main window */
user_data - > dlg . dialog_graph . window = window_new ( GTK_WINDOW_TOPLEVEL , " I/O Graphs " ) ;
vbox = gtk_vbox_new ( FALSE , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( user_data - > dlg . dialog_graph . window ) , vbox ) ;
gtk_widget_show ( vbox ) ;
create_draw_area ( user_data , vbox ) ;
hbox = gtk_hbox_new ( FALSE , 3 ) ;
gtk_box_pack_end ( GTK_BOX ( vbox ) , hbox , FALSE , FALSE , 5 ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( hbox ) , 3 ) ;
2004-10-01 07:14:50 +00:00
gtk_box_set_child_packing ( GTK_BOX ( vbox ) , hbox , FALSE , FALSE , 0 , GTK_PACK_START ) ;
gtk_widget_show ( hbox ) ;
create_filter_area ( user_data , hbox ) ;
create_ctrl_area ( user_data , hbox ) ;
dialog_graph_set_title ( user_data ) ;
hbox = dlg_button_row_new ( GTK_STOCK_CLOSE , NULL ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , hbox , FALSE , FALSE , 0 ) ;
gtk_widget_show ( hbox ) ;
2008-04-11 16:04:54 +00:00
bt_close = g_object_get_data ( G_OBJECT ( hbox ) , GTK_STOCK_CLOSE ) ;
2004-10-01 07:14:50 +00:00
window_set_cancel_button ( user_data - > dlg . dialog_graph . window , bt_close , window_cancel_button_cb ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( user_data - > dlg . dialog_graph . window , " delete_event " , G_CALLBACK ( window_delete_event_cb ) , NULL ) ;
2004-10-01 07:14:50 +00:00
gtk_widget_show ( user_data - > dlg . dialog_graph . window ) ;
window_present ( user_data - > dlg . dialog_graph . window ) ;
}
/****************************************************************************/
static void on_graph_bt_clicked ( GtkWidget * bt _U_ , user_data_t * user_data _U_ )
{
if ( user_data - > dlg . dialog_graph . window ! = NULL ) {
/* There's already a graph window; reactivate it. */
reactivate_window ( user_data - > dlg . dialog_graph . window ) ;
return ;
}
2007-05-17 18:41:07 +00:00
dialog_graph_init_window ( user_data ) ;
2004-10-01 07:14:50 +00:00
}
2003-09-24 07:48:12 +00:00
/****************************************************************************/
2009-02-20 17:13:44 +00:00
static void on_goto_bt_clicked_lst ( GtkWidget * bt _U_ , user_data_t * user_data _U_ )
2003-09-24 07:48:12 +00:00
{
2009-02-20 17:13:44 +00:00
GtkTreeIter iter ;
GtkTreeModel * model ;
GtkTreeSelection * selection ;
2003-09-24 07:48:12 +00:00
guint fnumber ;
2009-02-20 17:13:44 +00:00
selection = user_data - > dlg . selected_list_sel ;
if ( selection = = NULL )
return ;
if ( gtk_tree_selection_get_selected ( selection , & model , & iter ) ) {
gtk_tree_model_get ( model , & iter , PACKET_COLUMN , & fnumber , - 1 ) ;
2005-02-04 18:44:44 +00:00
cf_goto_frame ( & cfile , fnumber ) ;
2003-09-24 07:48:12 +00:00
}
2009-02-20 17:13:44 +00:00
}
2003-09-24 07:48:12 +00:00
static void draw_stat ( user_data_t * user_data ) ;
/****************************************************************************/
/* re-dissects all packets */
static void on_refresh_bt_clicked ( GtkWidget * bt _U_ , user_data_t * user_data _U_ )
{
2004-01-23 00:29:52 +00:00
GString * error_string ;
2007-05-17 18:41:07 +00:00
2004-10-01 07:14:50 +00:00
/* remove tap listener */
protect_thread_critical_region ( ) ;
remove_tap_listener ( user_data ) ;
unprotect_thread_critical_region ( ) ;
2004-01-23 00:29:52 +00:00
/* register tap listener */
2005-03-29 10:58:08 +00:00
error_string = register_tap_listener ( " rtp " , user_data , NULL ,
2004-01-23 00:29:52 +00:00
rtp_reset , rtp_packet , rtp_draw ) ;
if ( error_string ! = NULL ) {
2008-10-31 09:53:56 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , error_string - > str ) ;
2004-01-23 00:29:52 +00:00
g_string_free ( error_string , TRUE ) ;
return ;
}
/* retap all packets */
2005-09-14 08:59:41 +00:00
cf_retap_packets ( & cfile , FALSE ) ;
2004-01-23 00:29:52 +00:00
/* draw statistics info */
2003-09-24 07:48:12 +00:00
draw_stat ( user_data ) ;
2004-01-23 00:29:52 +00:00
2003-09-24 07:48:12 +00:00
}
2009-02-20 17:13:44 +00:00
static void on_next_bt_clicked_list ( GtkWidget * bt _U_ , user_data_t * user_data _U_ )
2003-09-25 19:35:14 +00:00
{
2009-02-20 17:13:44 +00:00
GtkTreeIter iter ;
GtkTreeModel * model ;
2003-09-25 19:35:14 +00:00
gchar * text ;
2009-02-20 17:13:44 +00:00
GtkTreeSelection * selection ;
GtkTreePath * path ;
2004-01-23 00:29:52 +00:00
2009-02-20 17:13:44 +00:00
selection = user_data - > dlg . selected_list_sel ;
2003-09-25 19:35:14 +00:00
2009-02-20 17:13:44 +00:00
if ( selection = = NULL )
return ;
2003-09-25 19:35:14 +00:00
2009-02-20 17:13:44 +00:00
try_again :
if ( gtk_tree_selection_get_selected ( selection , & model , & iter ) ) {
while ( gtk_tree_model_iter_next ( model , & iter ) ) {
gtk_tree_model_get ( model , & iter , STATUS_COLUMN , & text , - 1 ) ;
if ( strcmp ( text , OK_TEXT ) ! = 0 ) {
gtk_tree_selection_select_iter ( selection , & iter ) ;
path = gtk_tree_model_get_path ( model , & iter ) ;
gtk_tree_view_scroll_to_cell ( GTK_TREE_VIEW ( user_data - > dlg . selected_list ) ,
path ,
NULL , FALSE , 0 , 0 ) ;
gtk_tree_path_free ( path ) ;
g_free ( text ) ;
return ;
}
g_free ( text ) ;
}
/* wrap around */
if ( user_data - > dlg . number_of_nok > 1 ) {
/* Get the first iter and select it before starting over */
gtk_tree_model_get_iter_first ( model , & iter ) ;
gtk_tree_selection_select_iter ( selection , & iter ) ;
goto try_again ;
2003-09-25 19:35:14 +00:00
}
}
}
2003-09-24 07:48:12 +00:00
2009-02-20 17:13:44 +00:00
2003-09-24 07:48:12 +00:00
/****************************************************************************/
/* when we want to save the information */
static void save_csv_as_ok_cb ( GtkWidget * bt _U_ , gpointer fs /*user_data_t *user_data*/ _U_ )
{
gchar * g_dest ;
GtkWidget * rev , * forw , * both ;
user_data_t * user_data ;
2007-05-17 18:41:07 +00:00
2009-02-20 17:13:44 +00:00
GtkListStore * store ;
GtkTreeIter iter ;
GtkTreeSelection * selection ;
GtkTreeModel * model ;
/* To Hold data from the list row */
guint packet ; /* Packet */
guint sequence ; /* Sequence */
gfloat delta ; /* Delta(ms) */
gfloat jitter ; /* Jitter(ms) */
gfloat ipbw ; /* IP BW(kbps) */
gboolean marker ; /* Marker */
char * status_str ; /* Status */
char * date_str ; /* Date */
guint length ; /* Length */
2003-09-24 07:48:12 +00:00
FILE * fp ;
2009-02-20 17:13:44 +00:00
int j ;
2007-05-17 18:41:07 +00:00
2009-02-22 15:23:06 +00:00
g_dest = g_strdup ( gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER ( fs ) ) ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/* Perhaps the user specified a directory instead of a file.
2009-02-22 15:23:06 +00:00
* Check whether they did .
*/
2003-09-24 07:48:12 +00:00
if ( test_for_directory ( g_dest ) = = EISDIR ) {
/* It's a directory - set the file selection box to display it. */
set_last_open_dir ( g_dest ) ;
g_free ( g_dest ) ;
2004-06-01 17:33:37 +00:00
file_selection_set_current_folder ( fs , get_last_open_dir ( ) ) ;
2003-09-24 07:48:12 +00:00
return ;
}
2007-05-17 18:41:07 +00:00
2008-04-11 16:04:54 +00:00
rev = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( bt ) , " reversed_rb " ) ;
forw = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( bt ) , " forward_rb " ) ;
both = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( bt ) , " both_rb " ) ;
user_data = ( user_data_t * ) g_object_get_data ( G_OBJECT ( bt ) , " user_data " ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
if ( GTK_TOGGLE_BUTTON ( forw ) - > active | | GTK_TOGGLE_BUTTON ( both ) - > active ) {
2008-05-22 15:46:27 +00:00
fp = ws_fopen ( g_dest , " w " ) ;
2004-01-25 01:58:58 +00:00
if ( fp = = NULL ) {
2004-02-11 01:23:25 +00:00
open_failure_alert_box ( g_dest , errno , TRUE ) ;
2004-01-25 01:58:58 +00:00
return ;
}
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
if ( GTK_TOGGLE_BUTTON ( both ) - > active ) {
fprintf ( fp , " Forward \n " ) ;
2004-01-25 02:14:05 +00:00
if ( ferror ( fp ) ) {
2004-02-11 01:37:13 +00:00
write_failure_alert_box ( g_dest , errno ) ;
2004-01-25 02:14:05 +00:00
fclose ( fp ) ;
return ;
}
2003-09-24 07:48:12 +00:00
}
2007-05-17 18:41:07 +00:00
2004-10-11 05:23:31 +00:00
for ( j = 0 ; j < NUM_COLS ; j + + ) {
2003-09-24 07:48:12 +00:00
if ( j = = 0 ) {
2004-01-25 02:14:05 +00:00
fprintf ( fp , " %s " , titles [ j ] ) ;
2003-09-24 07:48:12 +00:00
} else {
2004-01-25 02:14:05 +00:00
fprintf ( fp , " ,%s " , titles [ j ] ) ;
2003-09-24 07:48:12 +00:00
}
}
fprintf ( fp , " \n " ) ;
2004-01-25 02:14:05 +00:00
if ( ferror ( fp ) ) {
2004-02-11 01:37:13 +00:00
write_failure_alert_box ( g_dest , errno ) ;
2004-01-25 02:14:05 +00:00
fclose ( fp ) ;
return ;
}
2009-02-20 17:13:44 +00:00
model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( user_data - > dlg . list_fwd ) ) ;
store = GTK_LIST_STORE ( model ) ;
if ( gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( store ) , & iter ) ) {
selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( user_data - > dlg . list_fwd ) ) ;
while ( gtk_tree_model_iter_next ( model , & iter ) ) {
gtk_tree_model_get ( GTK_TREE_MODEL ( store ) , & iter ,
0 , & packet ,
1 , & sequence ,
2 , & delta ,
3 , & jitter ,
4 , & ipbw ,
5 , & marker ,
6 , & status_str ,
7 , & date_str ,
8 , & length ,
- 1 ) ;
fprintf ( fp , " %u " , packet ) ;
fprintf ( fp , " ,%u " , sequence ) ;
fprintf ( fp , " ,%.2f " , delta ) ;
fprintf ( fp , " ,%.2f " , jitter ) ;
fprintf ( fp , " ,%.2f " , ipbw ) ;
fprintf ( fp , " ,%s " , marker ? " SET " : " " ) ;
fprintf ( fp , " ,%s " , status_str ) ;
fprintf ( fp , " ,%s " , date_str ) ;
fprintf ( fp , " ,%u " , length ) ;
fprintf ( fp , " \n " ) ;
}
if ( ferror ( fp ) ) {
write_failure_alert_box ( g_dest , errno ) ;
fclose ( fp ) ;
return ;
}
}
2007-05-17 18:41:07 +00:00
2004-01-25 02:14:05 +00:00
if ( fclose ( fp ) = = EOF ) {
2004-02-11 01:37:13 +00:00
write_failure_alert_box ( g_dest , errno ) ;
2004-01-25 02:14:05 +00:00
return ;
}
2003-09-24 07:48:12 +00:00
}
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
if ( GTK_TOGGLE_BUTTON ( rev ) - > active | | GTK_TOGGLE_BUTTON ( both ) - > active ) {
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
if ( GTK_TOGGLE_BUTTON ( both ) - > active ) {
2008-05-22 15:46:27 +00:00
fp = ws_fopen ( g_dest , " a " ) ;
2004-01-25 02:14:05 +00:00
if ( fp = = NULL ) {
2004-02-11 01:23:25 +00:00
open_failure_alert_box ( g_dest , errno , TRUE ) ;
2004-01-25 02:14:05 +00:00
return ;
}
2003-09-24 07:48:12 +00:00
fprintf ( fp , " \n Reverse \n " ) ;
2004-01-25 02:14:05 +00:00
if ( ferror ( fp ) ) {
2004-02-11 01:37:13 +00:00
write_failure_alert_box ( g_dest , errno ) ;
2004-01-25 02:14:05 +00:00
fclose ( fp ) ;
return ;
}
2003-09-24 07:48:12 +00:00
} else {
2008-05-22 15:46:27 +00:00
fp = ws_fopen ( g_dest , " w " ) ;
2004-01-25 02:14:05 +00:00
if ( fp = = NULL ) {
2004-02-11 01:23:25 +00:00
open_failure_alert_box ( g_dest , errno , TRUE ) ;
2004-01-25 02:14:05 +00:00
return ;
}
2003-09-24 07:48:12 +00:00
}
2004-10-11 05:23:31 +00:00
for ( j = 0 ; j < NUM_COLS ; j + + ) {
2003-09-24 07:48:12 +00:00
if ( j = = 0 ) {
2004-01-25 02:14:05 +00:00
fprintf ( fp , " %s " , titles [ j ] ) ;
2003-09-24 07:48:12 +00:00
} else {
2004-01-25 02:14:05 +00:00
fprintf ( fp , " ,%s " , titles [ j ] ) ;
2003-09-24 07:48:12 +00:00
}
}
fprintf ( fp , " \n " ) ;
2004-01-25 02:14:05 +00:00
if ( ferror ( fp ) ) {
2004-02-11 01:37:13 +00:00
write_failure_alert_box ( g_dest , errno ) ;
2004-01-25 02:14:05 +00:00
fclose ( fp ) ;
return ;
}
2009-02-20 17:13:44 +00:00
model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( user_data - > dlg . list_rev ) ) ;
store = GTK_LIST_STORE ( model ) ;
if ( gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( store ) , & iter ) ) {
selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( user_data - > dlg . list_rev ) ) ;
while ( gtk_tree_model_iter_next ( model , & iter ) ) {
gtk_tree_model_get ( GTK_TREE_MODEL ( store ) , & iter ,
0 , & packet ,
1 , & sequence ,
2 , & delta ,
3 , & jitter ,
4 , & ipbw ,
5 , & marker ,
6 , & status_str ,
7 , & date_str ,
8 , & length ,
- 1 ) ;
fprintf ( fp , " %u " , packet ) ;
fprintf ( fp , " ,%u " , sequence ) ;
fprintf ( fp , " ,%.2f " , delta ) ;
fprintf ( fp , " ,%.2f " , jitter ) ;
fprintf ( fp , " ,%.2f " , ipbw ) ;
fprintf ( fp , " ,%s " , marker ? " SET " : " " ) ;
fprintf ( fp , " ,%s " , status_str ) ;
fprintf ( fp , " ,%s " , date_str ) ;
fprintf ( fp , " ,%u " , length ) ;
fprintf ( fp , " \n " ) ;
}
if ( ferror ( fp ) ) {
write_failure_alert_box ( g_dest , errno ) ;
fclose ( fp ) ;
return ;
}
}
2004-01-25 02:14:05 +00:00
if ( fclose ( fp ) = = EOF ) {
2004-02-11 01:37:13 +00:00
write_failure_alert_box ( g_dest , errno ) ;
2004-01-25 02:14:05 +00:00
return ;
2003-09-24 07:48:12 +00:00
}
}
2004-05-26 03:49:24 +00:00
window_destroy ( GTK_WIDGET ( user_data - > dlg . save_csv_as_w ) ) ;
2003-09-24 07:48:12 +00:00
}
static void save_csv_as_destroy_cb ( GtkWidget * win _U_ , user_data_t * user_data _U_ )
{
user_data - > dlg . save_csv_as_w = NULL ;
}
/* when the user wants to save the csv information in a file */
static void save_csv_as_cb ( GtkWidget * bt _U_ , user_data_t * user_data _U_ )
{
GtkWidget * vertb ;
GtkWidget * table1 ;
GtkWidget * label_format ;
GtkWidget * channels_label ;
GSList * channels_group = NULL ;
GtkWidget * forward_rb ;
GtkWidget * reversed_rb ;
GtkWidget * both_rb ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
if ( user_data - > dlg . save_csv_as_w ! = NULL ) {
/* There's already a Save CSV info dialog box; reactivate it. */
reactivate_window ( user_data - > dlg . save_csv_as_w ) ;
return ;
}
2007-05-17 18:41:07 +00:00
2009-02-22 15:23:06 +00:00
user_data - > dlg . save_csv_as_w = gtk_file_chooser_dialog_new ( " Wireshark: Save Data As CSV " , GTK_WINDOW ( user_data - > dlg . notebook ) , GTK_FILE_CHOOSER_ACTION_SAVE ,
GTK_STOCK_OK , GTK_RESPONSE_ACCEPT ,
GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ,
NULL ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/* Container for each row of widgets */
vertb = gtk_vbox_new ( FALSE , 0 ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( vertb ) , 5 ) ;
2009-02-22 15:23:06 +00:00
gtk_file_chooser_set_extra_widget ( GTK_FILE_CHOOSER ( user_data - > dlg . save_csv_as_w ) , vertb ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( vertb ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
table1 = gtk_table_new ( 2 , 4 , FALSE ) ;
gtk_widget_show ( table1 ) ;
gtk_box_pack_start ( GTK_BOX ( vertb ) , table1 , FALSE , FALSE , 0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( table1 ) , 10 ) ;
gtk_table_set_row_spacings ( GTK_TABLE ( table1 ) , 20 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
label_format = gtk_label_new ( " Format: Comma Separated Values " ) ;
gtk_widget_show ( label_format ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , label_format , 0 , 3 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
channels_label = gtk_label_new ( " Channels: " ) ;
gtk_widget_show ( channels_label ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , channels_label , 0 , 1 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( channels_label ) , 0 , 0.5 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
forward_rb = gtk_radio_button_new_with_label ( channels_group , " forward " ) ;
2008-06-29 15:51:43 +00:00
channels_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( forward_rb ) ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( forward_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , forward_rb , 1 , 2 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
reversed_rb = gtk_radio_button_new_with_label ( channels_group , " reversed " ) ;
2008-06-29 15:51:43 +00:00
channels_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( reversed_rb ) ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( reversed_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , reversed_rb , 2 , 3 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
both_rb = gtk_radio_button_new_with_label ( channels_group , " both " ) ;
2008-06-29 15:51:43 +00:00
channels_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( both_rb ) ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( both_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , both_rb , 3 , 4 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( both_rb ) , TRUE ) ;
2007-05-17 18:41:07 +00:00
2009-02-22 15:23:06 +00:00
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_csv_as_w ) , " forward_rb " , forward_rb ) ;
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_csv_as_w ) , " reversed_rb " , reversed_rb ) ;
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_csv_as_w ) , " both_rb " , both_rb ) ;
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_csv_as_w ) , " user_data " , user_data ) ;
2007-05-17 18:41:07 +00:00
2009-02-22 15:23:06 +00:00
g_signal_connect ( user_data - > dlg . save_csv_as_w , " delete_event " ,
G_CALLBACK ( window_delete_event_cb ) , NULL ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( user_data - > dlg . save_csv_as_w , " destroy " ,
G_CALLBACK ( save_csv_as_destroy_cb ) , user_data ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
gtk_widget_show ( user_data - > dlg . save_csv_as_w ) ;
2005-03-29 10:58:08 +00:00
window_present ( user_data - > dlg . save_csv_as_w ) ;
2009-02-22 15:23:06 +00:00
if ( gtk_dialog_run ( GTK_DIALOG ( user_data - > dlg . save_csv_as_w ) ) = = GTK_RESPONSE_ACCEPT ) {
save_csv_as_ok_cb ( user_data - > dlg . save_csv_as_w , user_data - > dlg . save_csv_as_w ) ;
} else {
window_destroy ( user_data - > dlg . save_csv_as_w ) ;
}
2003-09-24 07:48:12 +00:00
}
/****************************************************************************/
static void save_voice_as_destroy_cb ( GtkWidget * win _U_ , user_data_t * user_data _U_ )
{
/* Note that we no longer have a Save voice info dialog box. */
user_data - > dlg . save_voice_as_w = NULL ;
}
/****************************************************************************/
/* here we save it into a file that user specified */
/* XXX what about endians here? could go something wrong? */
2005-09-01 05:41:59 +00:00
static gboolean copy_file ( gchar * dest , gint channels , gint format , user_data_t * user_data )
2003-09-24 07:48:12 +00:00
{
2008-11-08 23:36:12 +00:00
FILE * to_stream , * forw_stream , * rev_stream ;
size_t fwritten , rwritten ;
int f_rawvalue , r_rawvalue , rawvalue ;
2007-12-28 13:01:55 +00:00
gint16 sample ;
gchar pd [ 4 ] ;
2003-09-24 07:48:12 +00:00
guint32 f_write_silence = 0 ;
guint32 r_write_silence = 0 ;
progdlg_t * progbar ;
guint32 progbar_count , progbar_quantum , progbar_nextstep = 0 , count = 0 ;
gboolean stop_flag = FALSE ;
2007-05-02 12:07:46 +00:00
size_t nchars ;
2003-09-24 07:48:12 +00:00
2008-11-08 23:36:12 +00:00
forw_stream = ws_fopen ( user_data - > f_tempname , " rb " ) ;
if ( forw_stream = = NULL )
2003-09-24 07:48:12 +00:00
return FALSE ;
2008-11-08 23:36:12 +00:00
rev_stream = ws_fopen ( user_data - > r_tempname , " rb " ) ;
if ( rev_stream = = NULL ) {
fclose ( forw_stream ) ;
2003-09-24 07:48:12 +00:00
return FALSE ;
}
/* open file for saving */
2008-11-08 23:36:12 +00:00
to_stream = ws_fopen ( dest , " wb " ) ;
if ( to_stream = = NULL ) {
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
2003-09-24 07:48:12 +00:00
return FALSE ;
}
2007-12-28 13:01:55 +00:00
progbar = create_progress_dlg ( " Saving voice in a file " , dest , TRUE , & stop_flag ) ;
2003-09-24 07:48:12 +00:00
2005-09-01 05:41:59 +00:00
if ( format = = SAVE_AU_FORMAT ) /* au format */
{
/* First we write the .au header. XXX Hope this is endian independant */
/* the magic word 0x2e736e64 == .snd */
2007-12-28 13:01:55 +00:00
phtonl ( pd , 0x2e736e64 ) ;
2008-11-08 23:36:12 +00:00
nchars = fwrite ( pd , 1 , 4 , to_stream ) ;
2005-09-01 05:41:59 +00:00
/* header offset == 24 bytes */
2007-12-28 13:01:55 +00:00
phtonl ( pd , 24 ) ;
2008-11-08 23:36:12 +00:00
nchars = fwrite ( pd , 1 , 4 , to_stream ) ;
/* total length; it is permitted to set this to 0xffffffff */
2007-12-28 13:01:55 +00:00
phtonl ( pd , - 1 ) ;
2008-11-08 23:36:12 +00:00
nchars = fwrite ( pd , 1 , 4 , to_stream ) ;
2007-12-28 13:01:55 +00:00
/* encoding format == 16-bit linear PCM */
phtonl ( pd , 3 ) ;
2008-11-08 23:36:12 +00:00
nchars = fwrite ( pd , 1 , 4 , to_stream ) ;
2005-09-01 05:41:59 +00:00
/* sample rate == 8000 Hz */
2007-12-28 13:01:55 +00:00
phtonl ( pd , 8000 ) ;
2008-11-08 23:36:12 +00:00
nchars = fwrite ( pd , 1 , 4 , to_stream ) ;
2005-09-01 05:41:59 +00:00
/* channels == 1 */
2007-12-28 13:01:55 +00:00
phtonl ( pd , 1 ) ;
2008-11-08 23:36:12 +00:00
nchars = fwrite ( pd , 1 , 4 , to_stream ) ;
2007-05-17 18:41:07 +00:00
2005-09-01 05:41:59 +00:00
switch ( channels ) {
/* only forward direction */
2005-10-29 15:34:16 +00:00
case SAVE_FORWARD_DIRECTION_MASK : {
2005-09-01 05:41:59 +00:00
progbar_count = user_data - > forward . saveinfo . count ;
progbar_quantum = user_data - > forward . saveinfo . count / 100 ;
2008-11-08 23:36:12 +00:00
while ( ( f_rawvalue = getc ( forw_stream ) ) ! = EOF ) {
2007-05-17 18:41:07 +00:00
if ( stop_flag )
2005-09-01 05:41:59 +00:00
break ;
if ( ( count > progbar_nextstep ) & & ( count < = progbar_count ) ) {
2007-05-17 18:41:07 +00:00
update_progress_dlg ( progbar ,
2005-09-01 05:41:59 +00:00
( gfloat ) count / progbar_count , " Saving " ) ;
progbar_nextstep = progbar_nextstep + progbar_quantum ;
}
count + + ;
if ( user_data - > forward . statinfo . pt = = PT_PCMU ) {
2008-11-10 13:22:18 +00:00
sample = ulaw2linear ( ( unsigned char ) f_rawvalue ) ;
2007-12-28 13:01:55 +00:00
phtons ( pd , sample ) ;
2005-09-01 05:41:59 +00:00
}
else if ( user_data - > forward . statinfo . pt = = PT_PCMA ) {
2008-11-10 13:22:18 +00:00
sample = alaw2linear ( ( unsigned char ) f_rawvalue ) ;
2007-12-28 13:01:55 +00:00
phtons ( pd , sample ) ;
2005-09-01 05:41:59 +00:00
}
else {
2008-11-08 23:36:12 +00:00
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
fclose ( to_stream ) ;
2005-09-01 05:41:59 +00:00
destroy_progress_dlg ( progbar ) ;
return FALSE ;
}
2007-05-17 18:41:07 +00:00
2008-11-08 23:36:12 +00:00
fwritten = fwrite ( pd , 1 , 2 , to_stream ) ;
if ( fwritten < 2 ) {
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
fclose ( to_stream ) ;
2005-09-01 05:41:59 +00:00
destroy_progress_dlg ( progbar ) ;
return FALSE ;
}
2003-09-24 07:48:12 +00:00
}
2005-09-01 05:41:59 +00:00
break ;
}
/* only reversed direction */
2005-10-29 15:34:16 +00:00
case SAVE_REVERSE_DIRECTION_MASK : {
2005-09-01 05:41:59 +00:00
progbar_count = user_data - > reversed . saveinfo . count ;
progbar_quantum = user_data - > reversed . saveinfo . count / 100 ;
2008-11-08 23:36:12 +00:00
while ( ( r_rawvalue = getc ( rev_stream ) ) ! = EOF ) {
2007-05-17 18:41:07 +00:00
if ( stop_flag )
2005-09-01 05:41:59 +00:00
break ;
if ( ( count > progbar_nextstep ) & & ( count < = progbar_count ) ) {
2007-05-17 18:41:07 +00:00
update_progress_dlg ( progbar ,
2005-09-01 05:41:59 +00:00
( gfloat ) count / progbar_count , " Saving " ) ;
progbar_nextstep = progbar_nextstep + progbar_quantum ;
}
count + + ;
2008-08-08 19:57:50 +00:00
if ( user_data - > reversed . statinfo . pt = = PT_PCMU ) {
2008-11-10 13:22:18 +00:00
sample = ulaw2linear ( ( unsigned char ) r_rawvalue ) ;
2007-12-28 13:01:55 +00:00
phtons ( pd , sample ) ;
2005-09-01 05:41:59 +00:00
}
2008-08-08 19:57:50 +00:00
else if ( user_data - > reversed . statinfo . pt = = PT_PCMA ) {
2008-11-10 13:22:18 +00:00
sample = alaw2linear ( ( unsigned char ) r_rawvalue ) ;
2007-12-28 13:01:55 +00:00
phtons ( pd , sample ) ;
2005-09-01 05:41:59 +00:00
}
else {
2008-11-08 23:36:12 +00:00
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
fclose ( to_stream ) ;
2005-09-01 05:41:59 +00:00
destroy_progress_dlg ( progbar ) ;
return FALSE ;
}
2007-05-17 18:41:07 +00:00
2008-11-08 23:36:12 +00:00
rwritten = fwrite ( pd , 1 , 2 , to_stream ) ;
if ( rwritten < 2 ) {
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
fclose ( to_stream ) ;
2005-09-01 05:41:59 +00:00
destroy_progress_dlg ( progbar ) ;
return FALSE ;
}
2003-09-24 07:48:12 +00:00
}
2005-09-01 05:41:59 +00:00
break ;
2003-09-24 07:48:12 +00:00
}
2005-09-01 05:41:59 +00:00
/* both directions */
2005-10-29 15:34:16 +00:00
case SAVE_BOTH_DIRECTION_MASK : {
2007-05-17 18:41:07 +00:00
( user_data - > forward . saveinfo . count > user_data - > reversed . saveinfo . count ) ?
( progbar_count = user_data - > forward . saveinfo . count ) :
2005-09-01 05:41:59 +00:00
( progbar_count = user_data - > reversed . saveinfo . count ) ;
progbar_quantum = progbar_count / 100 ;
2007-05-17 18:41:07 +00:00
/* since conversation in one way can start later than in the other one,
2005-09-01 05:41:59 +00:00
* we have to write some silence information for one channel */
if ( user_data - > forward . statinfo . start_time > user_data - > reversed . statinfo . start_time ) {
f_write_silence = ( guint32 )
( ( user_data - > forward . statinfo . start_time - user_data - > reversed . statinfo . start_time ) * 8000 ) ;
2003-09-24 07:48:12 +00:00
}
2005-09-01 05:41:59 +00:00
else if ( user_data - > forward . statinfo . start_time < user_data - > reversed . statinfo . start_time ) {
r_write_silence = ( guint32 )
( ( user_data - > reversed . statinfo . start_time - user_data - > forward . statinfo . start_time ) * 8000 ) ;
}
for ( ; ; ) {
2007-05-17 18:41:07 +00:00
if ( stop_flag )
2005-09-01 05:41:59 +00:00
break ;
if ( ( count > progbar_nextstep ) & & ( count < = progbar_count ) ) {
2007-05-17 18:41:07 +00:00
update_progress_dlg ( progbar ,
2005-09-01 05:41:59 +00:00
( gfloat ) count / progbar_count , " Saving " ) ;
progbar_nextstep = progbar_nextstep + progbar_quantum ;
}
count + + ;
if ( f_write_silence > 0 ) {
2008-11-08 23:36:12 +00:00
r_rawvalue = getc ( rev_stream ) ;
2005-10-29 15:34:16 +00:00
switch ( user_data - > forward . statinfo . reg_pt ) {
case PT_PCMU :
2008-11-08 23:36:12 +00:00
f_rawvalue = SILENCE_PCMU ;
2005-10-29 15:34:16 +00:00
break ;
case PT_PCMA :
2008-11-08 23:36:12 +00:00
f_rawvalue = SILENCE_PCMA ;
break ;
default :
f_rawvalue = 0 ;
2005-10-29 15:34:16 +00:00
break ;
2007-05-17 18:41:07 +00:00
}
2005-09-01 05:41:59 +00:00
f_write_silence - - ;
}
else if ( r_write_silence > 0 ) {
2008-11-08 23:36:12 +00:00
f_rawvalue = getc ( forw_stream ) ;
2008-08-08 19:57:50 +00:00
switch ( user_data - > reversed . statinfo . reg_pt ) {
2005-10-29 15:34:16 +00:00
case PT_PCMU :
2008-11-08 23:36:12 +00:00
r_rawvalue = SILENCE_PCMU ;
2005-10-29 15:34:16 +00:00
break ;
case PT_PCMA :
2008-11-08 23:36:12 +00:00
r_rawvalue = SILENCE_PCMA ;
break ;
default :
r_rawvalue = 0 ;
2005-10-29 15:34:16 +00:00
break ;
2007-05-17 18:41:07 +00:00
}
2005-09-01 05:41:59 +00:00
r_write_silence - - ;
}
else {
2008-11-08 23:36:12 +00:00
f_rawvalue = getc ( forw_stream ) ;
r_rawvalue = getc ( rev_stream ) ;
2005-09-01 05:41:59 +00:00
}
2008-11-08 23:36:12 +00:00
if ( ( r_rawvalue = = EOF ) & & ( f_rawvalue = = EOF ) )
2005-09-01 05:41:59 +00:00
break ;
if ( ( user_data - > forward . statinfo . pt = = PT_PCMU ) & & ( user_data - > reversed . statinfo . pt = = PT_PCMU ) ) {
2008-11-10 13:22:18 +00:00
sample = ( ulaw2linear ( ( unsigned char ) r_rawvalue ) + ulaw2linear ( ( unsigned char ) f_rawvalue ) ) / 2 ;
2007-12-28 13:01:55 +00:00
phtons ( pd , sample ) ;
2005-09-01 05:41:59 +00:00
}
else if ( ( user_data - > forward . statinfo . pt = = PT_PCMA ) & & ( user_data - > reversed . statinfo . pt = = PT_PCMA ) ) {
2008-11-10 13:22:18 +00:00
sample = ( alaw2linear ( ( unsigned char ) r_rawvalue ) + alaw2linear ( ( unsigned char ) f_rawvalue ) ) / 2 ;
2007-12-28 13:01:55 +00:00
phtons ( pd , sample ) ;
2005-09-01 05:41:59 +00:00
}
else
{
2008-11-08 23:36:12 +00:00
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
fclose ( to_stream ) ;
2005-09-01 05:41:59 +00:00
destroy_progress_dlg ( progbar ) ;
return FALSE ;
}
2007-05-17 18:41:07 +00:00
2008-11-08 23:36:12 +00:00
rwritten = fwrite ( pd , 1 , 2 , to_stream ) ;
if ( rwritten < 2 ) {
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
fclose ( to_stream ) ;
2005-09-01 05:41:59 +00:00
destroy_progress_dlg ( progbar ) ;
return FALSE ;
}
2003-09-24 07:48:12 +00:00
}
}
}
2005-09-01 05:41:59 +00:00
}
else if ( format = = SAVE_RAW_FORMAT ) /* raw format */
{
2008-11-08 23:36:12 +00:00
FILE * stream ;
2005-09-01 05:41:59 +00:00
switch ( channels ) {
/* only forward direction */
2005-10-29 15:34:16 +00:00
case SAVE_FORWARD_DIRECTION_MASK : {
2005-09-01 05:41:59 +00:00
progbar_count = user_data - > forward . saveinfo . count ;
progbar_quantum = user_data - > forward . saveinfo . count / 100 ;
2008-11-08 23:36:12 +00:00
stream = forw_stream ;
2005-09-01 05:41:59 +00:00
break ;
2003-09-24 07:48:12 +00:00
}
2005-09-01 05:41:59 +00:00
/* only reversed direction */
2005-10-29 15:34:16 +00:00
case SAVE_REVERSE_DIRECTION_MASK : {
2005-09-01 05:41:59 +00:00
progbar_count = user_data - > reversed . saveinfo . count ;
progbar_quantum = user_data - > reversed . saveinfo . count / 100 ;
2008-11-08 23:36:12 +00:00
stream = rev_stream ;
2005-09-01 05:41:59 +00:00
break ;
2003-09-24 07:48:12 +00:00
}
2005-09-01 05:41:59 +00:00
default : {
2008-11-08 23:36:12 +00:00
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
fclose ( to_stream ) ;
2005-09-01 05:41:59 +00:00
destroy_progress_dlg ( progbar ) ;
return FALSE ;
}
}
2007-05-17 18:41:07 +00:00
2005-09-01 05:41:59 +00:00
/* XXX how do you just copy the file? */
2008-11-08 23:36:12 +00:00
while ( ( rawvalue = getc ( stream ) ) ! = EOF ) {
2007-05-17 18:41:07 +00:00
if ( stop_flag )
2005-09-01 05:41:59 +00:00
break ;
if ( ( count > progbar_nextstep ) & & ( count < = progbar_count ) ) {
2007-05-17 18:41:07 +00:00
update_progress_dlg ( progbar ,
2005-09-01 05:41:59 +00:00
( gfloat ) count / progbar_count , " Saving " ) ;
progbar_nextstep = progbar_nextstep + progbar_quantum ;
}
count + + ;
2008-11-08 23:36:12 +00:00
if ( putc ( rawvalue , to_stream ) = = EOF ) {
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
fclose ( to_stream ) ;
2005-09-01 05:41:59 +00:00
destroy_progress_dlg ( progbar ) ;
return FALSE ;
2003-09-24 07:48:12 +00:00
}
}
}
2005-09-01 05:41:59 +00:00
2003-09-24 07:48:12 +00:00
destroy_progress_dlg ( progbar ) ;
2008-11-08 23:36:12 +00:00
fclose ( forw_stream ) ;
fclose ( rev_stream ) ;
fclose ( to_stream ) ;
2003-09-24 07:48:12 +00:00
return TRUE ;
}
/****************************************************************************/
/* the user wants to save in a file */
/* XXX support for different formats is currently commented out */
static void save_voice_as_ok_cb ( GtkWidget * ok_bt _U_ , gpointer fs _U_ )
{
gchar * g_dest ;
2005-10-29 15:34:16 +00:00
/*GtkWidget *wav, *sw;*/
2005-09-01 05:41:59 +00:00
GtkWidget * au , * raw ;
2003-09-24 07:48:12 +00:00
GtkWidget * rev , * forw , * both ;
user_data_t * user_data ;
2005-09-01 05:41:59 +00:00
gint channels , format ;
2007-05-17 18:41:07 +00:00
2009-02-22 15:23:06 +00:00
g_dest = g_strdup ( gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER ( fs ) ) ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/* Perhaps the user specified a directory instead of a file.
Check whether they did . */
if ( test_for_directory ( g_dest ) = = EISDIR ) {
/* It's a directory - set the file selection box to display it. */
set_last_open_dir ( g_dest ) ;
g_free ( g_dest ) ;
2004-06-01 17:33:37 +00:00
file_selection_set_current_folder ( fs , get_last_open_dir ( ) ) ;
2003-09-24 07:48:12 +00:00
return ;
}
2007-05-17 18:41:07 +00:00
2008-04-11 16:04:54 +00:00
/*wav = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), "wav_rb");
sw = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( ok_bt ) , " sw_rb " ) ; */
au = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( ok_bt ) , " au_rb " ) ;
raw = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( ok_bt ) , " raw_rb " ) ;
rev = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( ok_bt ) , " reversed_rb " ) ;
forw = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( ok_bt ) , " forward_rb " ) ;
both = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( ok_bt ) , " both_rb " ) ;
user_data = ( user_data_t * ) g_object_get_data ( G_OBJECT ( ok_bt ) , " user_data " ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/* XXX user clicks the ok button, but we know we can't save the voice info because f.e.
* we don ' t support that codec . So we pop up a warning . Maybe it would be better to
* disable the ok button or disable the buttons for direction if only one is not ok . The
2007-05-17 18:41:07 +00:00
* problem is if we open the save voice dialog and then click the refresh button and maybe
2003-09-24 07:48:12 +00:00
* the state changes , so we can ' t save anymore . In this case we should be able to update
* the buttons . For now it is easier if we put the warning when the ok button is pressed .
*/
2007-05-17 18:41:07 +00:00
2005-09-01 05:41:59 +00:00
/* we can not save in both directions */
2003-09-25 19:35:14 +00:00
if ( ( user_data - > forward . saveinfo . saved = = FALSE ) & & ( user_data - > reversed . saveinfo . saved = = FALSE ) & & ( GTK_TOGGLE_BUTTON ( both ) - > active ) ) {
2003-09-24 07:48:12 +00:00
/* there are many combinations here, we just exit when first matches */
2007-05-17 18:41:07 +00:00
if ( ( user_data - > forward . saveinfo . error_type = = TAP_RTP_WRONG_CODEC ) | |
2003-09-25 19:35:14 +00:00
( user_data - > reversed . saveinfo . error_type = = TAP_RTP_WRONG_CODEC ) )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save in a file: Unsupported codec! " ) ;
2007-05-17 18:41:07 +00:00
else if ( ( user_data - > forward . saveinfo . error_type = = TAP_RTP_WRONG_LENGTH ) | |
2003-09-25 19:35:14 +00:00
( user_data - > reversed . saveinfo . error_type = = TAP_RTP_WRONG_LENGTH ) )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save in a file: Wrong length of captured packets! " ) ;
2007-05-17 18:41:07 +00:00
else if ( ( user_data - > forward . saveinfo . error_type = = TAP_RTP_PADDING_ERROR ) | |
2003-09-25 19:35:14 +00:00
( user_data - > reversed . saveinfo . error_type = = TAP_RTP_PADDING_ERROR ) )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save in a file: RTP data with padding! " ) ;
2007-05-17 18:41:07 +00:00
else if ( ( user_data - > forward . saveinfo . error_type = = TAP_RTP_SHORT_FRAME ) | |
2004-01-31 09:48:26 +00:00
( user_data - > reversed . saveinfo . error_type = = TAP_RTP_SHORT_FRAME ) )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2004-01-31 09:48:26 +00:00
" Can't save in a file: Not all data in all packets was captured! " ) ;
2005-09-01 05:41:59 +00:00
else
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save in a file: File I/O problem! " ) ;
return ;
}
/* we can not save forward direction */
2003-09-25 19:35:14 +00:00
else if ( ( user_data - > forward . saveinfo . saved = = FALSE ) & & ( ( GTK_TOGGLE_BUTTON ( forw ) - > active ) | |
2007-05-17 18:41:07 +00:00
( GTK_TOGGLE_BUTTON ( both ) - > active ) ) ) {
2003-09-25 19:35:14 +00:00
if ( user_data - > forward . saveinfo . error_type = = TAP_RTP_WRONG_CODEC )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save forward direction in a file: Unsupported codec! " ) ;
2003-09-25 19:35:14 +00:00
else if ( user_data - > forward . saveinfo . error_type = = TAP_RTP_WRONG_LENGTH )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save forward direction in a file: Wrong length of captured packets! " ) ;
2003-09-25 19:35:14 +00:00
else if ( user_data - > forward . saveinfo . error_type = = TAP_RTP_PADDING_ERROR )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save forward direction in a file: RTP data with padding! " ) ;
2004-01-31 09:48:26 +00:00
else if ( user_data - > forward . saveinfo . error_type = = TAP_RTP_SHORT_FRAME )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2004-01-31 09:48:26 +00:00
" Can't save forward direction in a file: Not all data in all packets was captured! " ) ;
2003-09-24 07:48:12 +00:00
else
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save forward direction in a file: File I/O problem! " ) ;
return ;
}
/* we can not save reversed direction */
2003-09-25 19:35:14 +00:00
else if ( ( user_data - > reversed . saveinfo . saved = = FALSE ) & & ( ( GTK_TOGGLE_BUTTON ( rev ) - > active ) | |
2007-05-17 18:41:07 +00:00
( GTK_TOGGLE_BUTTON ( both ) - > active ) ) ) {
2003-09-25 19:35:14 +00:00
if ( user_data - > reversed . saveinfo . error_type = = TAP_RTP_WRONG_CODEC )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save reversed direction in a file: Unsupported codec! " ) ;
2003-09-25 19:35:14 +00:00
else if ( user_data - > reversed . saveinfo . error_type = = TAP_RTP_WRONG_LENGTH )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save reversed direction in a file: Wrong length of captured packets! " ) ;
2003-09-25 19:35:14 +00:00
else if ( user_data - > reversed . saveinfo . error_type = = TAP_RTP_PADDING_ERROR )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save reversed direction in a file: RTP data with padding! " ) ;
2008-08-08 19:57:50 +00:00
else if ( user_data - > reversed . saveinfo . error_type = = TAP_RTP_SHORT_FRAME )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2004-01-31 09:48:26 +00:00
" Can't save reversed direction in a file: Not all data in all packets was captured! " ) ;
2003-09-25 19:35:14 +00:00
else if ( user_data - > reversed . saveinfo . error_type = = TAP_RTP_NO_DATA )
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save reversed direction in a file: No RTP data! " ) ;
else
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2003-09-24 07:48:12 +00:00
" Can't save reversed direction in a file: File I/O problem! " ) ;
return ;
}
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/*if (GTK_TOGGLE_BUTTON (wav)->active)
2006-03-07 16:39:54 +00:00
format = SAVE_WAV_FORMAT ;
2005-09-01 05:41:59 +00:00
else */ if ( GTK_TOGGLE_BUTTON ( au ) - > active )
2006-03-07 16:39:54 +00:00
format = SAVE_AU_FORMAT ;
/*else if (GTK_TOGGLE_BUTTON (sw)->active)
format = SAVE_SW_FORMAT ; */
2005-09-01 05:41:59 +00:00
else if ( GTK_TOGGLE_BUTTON ( raw ) - > active )
2006-03-07 16:39:54 +00:00
format = SAVE_RAW_FORMAT ;
else
format = SAVE_NONE_FORMAT ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
if ( GTK_TOGGLE_BUTTON ( rev ) - > active )
2005-09-01 05:41:59 +00:00
channels = SAVE_REVERSE_DIRECTION_MASK ;
2003-09-24 07:48:12 +00:00
else if ( GTK_TOGGLE_BUTTON ( both ) - > active )
2005-09-01 05:41:59 +00:00
channels = SAVE_BOTH_DIRECTION_MASK ;
2007-05-17 18:41:07 +00:00
else
2005-09-01 05:41:59 +00:00
channels = SAVE_FORWARD_DIRECTION_MASK ;
/* direction/format validity*/
if ( format = = SAVE_AU_FORMAT )
{
/* make sure streams are alaw/ulaw */
if ( ( channels & SAVE_FORWARD_DIRECTION_MASK ) & & ( user_data - > forward . statinfo . pt ! = PT_PCMA ) & & ( user_data - > forward . statinfo . pt ! = PT_PCMU ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
" Can't save in a file: saving in au format supported only for alaw/ulaw streams " ) ;
return ;
}
if ( ( channels & SAVE_REVERSE_DIRECTION_MASK ) & & ( user_data - > reversed . statinfo . pt ! = PT_PCMA ) & & ( user_data - > reversed . statinfo . pt ! = PT_PCMU ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
" Can't save in a file: saving in au format supported only for alaw/ulaw streams " ) ;
return ;
}
/* make sure pt's don't differ */
2005-10-29 15:34:16 +00:00
if ( ( channels = = SAVE_BOTH_DIRECTION_MASK ) & & ( user_data - > forward . statinfo . pt ! = user_data - > reversed . statinfo . pt ) ) {
2005-09-01 05:41:59 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
" Can't save in a file: Forward and reverse direction differ in type " ) ;
return ;
}
}
else if ( format = = SAVE_RAW_FORMAT )
{
/* can't save raw in both directions */
2005-10-29 15:34:16 +00:00
if ( channels = = SAVE_BOTH_DIRECTION_MASK ) {
2005-09-01 05:41:59 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
" Can't save in a file: Unable to save raw data in both directions " ) ;
return ;
}
}
else
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
" Can't save in a file: Invalid save format " ) ;
return ;
}
2007-05-17 18:41:07 +00:00
2005-09-01 05:41:59 +00:00
if ( ! copy_file ( g_dest , channels , format , user_data ) ) {
2004-01-31 03:22:42 +00:00
/* XXX - report the error type! */
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2006-10-17 01:29:55 +00:00
" An error occurred while saving voice in a file! " ) ;
2003-09-24 07:48:12 +00:00
return ;
}
2007-05-17 18:41:07 +00:00
2004-05-26 03:49:24 +00:00
window_destroy ( GTK_WIDGET ( user_data - > dlg . save_voice_as_w ) ) ;
2003-09-24 07:48:12 +00:00
}
/****************************************************************************/
/* when the user wants to save the voice information in a file */
/* XXX support for different formats is currently commented out */
static void on_save_bt_clicked ( GtkWidget * bt _U_ , user_data_t * user_data _U_ )
{
GtkWidget * vertb ;
GtkWidget * table1 ;
GtkWidget * label_format ;
GtkWidget * channels_label ;
2005-09-01 05:41:59 +00:00
GSList * format_group = NULL ;
2003-09-24 07:48:12 +00:00
GSList * channels_group = NULL ;
GtkWidget * forward_rb ;
GtkWidget * reversed_rb ;
GtkWidget * both_rb ;
2005-09-01 05:41:59 +00:00
/*GtkWidget *wav_rb; GtkWidget *sw_rb;*/
GtkWidget * au_rb ;
GtkWidget * raw_rb ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/* if we can't save in a file: wrong codec, cut packets or other errors */
2007-05-17 18:41:07 +00:00
/* shold the error arise here or later when you click ok button ?
2003-09-24 07:48:12 +00:00
* if we do it here , then we must disable the refresh button , so we don ' t do it here */
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
if ( user_data - > dlg . save_voice_as_w ! = NULL ) {
/* There's already a Save voice info dialog box; reactivate it. */
reactivate_window ( user_data - > dlg . save_voice_as_w ) ;
return ;
}
2007-05-17 18:41:07 +00:00
2004-05-26 03:49:24 +00:00
/* XXX - use file_selection from dlg_utils instead! */
2009-02-22 15:23:06 +00:00
user_data - > dlg . save_voice_as_w = gtk_file_chooser_dialog_new ( " Wireshark: Save Payload As ... " , GTK_WINDOW ( user_data - > dlg . notebook ) , GTK_FILE_CHOOSER_ACTION_SAVE ,
GTK_STOCK_OK , GTK_RESPONSE_ACCEPT ,
GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ,
NULL ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/* Container for each row of widgets */
vertb = gtk_vbox_new ( FALSE , 0 ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( vertb ) , 5 ) ;
2009-02-22 15:23:06 +00:00
gtk_file_chooser_set_extra_widget ( GTK_FILE_CHOOSER ( user_data - > dlg . save_voice_as_w ) , vertb ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( vertb ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
table1 = gtk_table_new ( 2 , 4 , FALSE ) ;
gtk_widget_show ( table1 ) ;
gtk_box_pack_start ( GTK_BOX ( vertb ) , table1 , FALSE , FALSE , 0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( table1 ) , 10 ) ;
gtk_table_set_row_spacings ( GTK_TABLE ( table1 ) , 20 ) ;
2007-05-17 18:41:07 +00:00
2005-09-01 05:41:59 +00:00
/*label_format = gtk_label_new ("Format: .au (ulaw, 8 bit, 8000 Hz, mono) ");
gtk_widget_show ( label_format ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , label_format , 0 , 3 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ; */
label_format = gtk_label_new ( " Format: " ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( label_format ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , label_format , 0 , 3 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2005-09-01 05:41:59 +00:00
gtk_misc_set_alignment ( GTK_MISC ( label_format ) , 0 , 0.5 ) ;
raw_rb = gtk_radio_button_new_with_label ( format_group , " .raw " ) ;
2008-06-29 15:51:43 +00:00
format_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( raw_rb ) ) ;
2005-09-01 05:41:59 +00:00
gtk_widget_show ( raw_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , raw_rb , 1 , 2 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
2005-09-01 05:41:59 +00:00
au_rb = gtk_radio_button_new_with_label ( format_group , " .au " ) ;
2008-06-29 15:51:43 +00:00
format_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( au_rb ) ) ;
2005-09-01 05:41:59 +00:00
gtk_widget_show ( au_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , au_rb , 3 , 4 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
/* we support .au - ulaw*/
2003-09-24 07:48:12 +00:00
/* wav_rb = gtk_radio_button_new_with_label (format_group, ".wav");
2008-06-29 15:51:43 +00:00
format_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( wav_rb ) ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( wav_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , wav_rb , 1 , 2 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
sw_rb = gtk_radio_button_new_with_label ( format_group , " 8 kHz, 16 bit " ) ;
2008-06-29 15:51:43 +00:00
format_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( sw_rb ) ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( sw_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , sw_rb , 2 , 3 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
au_rb = gtk_radio_button_new_with_label ( format_group , " .au " ) ;
2008-06-29 15:51:43 +00:00
format_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( au_rb ) ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( au_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , au_rb , 3 , 4 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
*/
2005-10-29 15:34:16 +00:00
2003-09-24 07:48:12 +00:00
channels_label = gtk_label_new ( " Channels: " ) ;
gtk_widget_show ( channels_label ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , channels_label , 0 , 1 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( channels_label ) , 0 , 0.5 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
forward_rb = gtk_radio_button_new_with_label ( channels_group , " forward " ) ;
2008-06-29 15:51:43 +00:00
channels_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( forward_rb ) ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( forward_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , forward_rb , 1 , 2 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
reversed_rb = gtk_radio_button_new_with_label ( channels_group , " reversed " ) ;
2008-06-29 15:51:43 +00:00
channels_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( reversed_rb ) ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( reversed_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , reversed_rb , 2 , 3 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
both_rb = gtk_radio_button_new_with_label ( channels_group , " both " ) ;
2008-06-29 15:51:43 +00:00
channels_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( both_rb ) ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( both_rb ) ;
gtk_table_attach ( GTK_TABLE ( table1 ) , both_rb , 3 , 4 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( both_rb ) , TRUE ) ;
2007-05-17 18:41:07 +00:00
/* if one direction is nok we don't allow saving
2003-09-24 07:48:12 +00:00
XXX this is not ok since the user can click the refresh button and cause changes
but we can not update this window . So we move all the decision on the time the ok
button is clicked
if ( user_data - > forward . saved = = FALSE ) {
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( reversed_rb ) , TRUE ) ;
gtk_widget_set_sensitive ( forward_rb , FALSE ) ;
gtk_widget_set_sensitive ( both_rb , FALSE ) ;
}
else if ( user_data - > reversed . saved = = FALSE ) {
gtk_widget_set_sensitive ( reversed_rb , FALSE ) ;
gtk_widget_set_sensitive ( both_rb , FALSE ) ;
}
*/
2007-05-17 18:41:07 +00:00
2008-04-11 16:04:54 +00:00
/*g_object_set_data(G_OBJECT(ok_bt), "wav_rb", wav_rb);*/
2009-02-22 15:23:06 +00:00
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_voice_as_w ) , " au_rb " , au_rb ) ;
2008-04-11 16:04:54 +00:00
/*g_object_set_data(G_OBJECT(ok_bt), "sw_rb", sw_rb);*/
2009-02-22 15:23:06 +00:00
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_voice_as_w ) , " raw_rb " , raw_rb ) ;
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_voice_as_w ) , " forward_rb " , forward_rb ) ;
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_voice_as_w ) , " reversed_rb " , reversed_rb ) ;
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_voice_as_w ) , " both_rb " , both_rb ) ;
g_object_set_data ( G_OBJECT ( user_data - > dlg . save_voice_as_w ) , " user_data " , user_data ) ;
2004-05-26 03:49:24 +00:00
2008-04-11 23:16:06 +00:00
g_signal_connect ( user_data - > dlg . save_voice_as_w , " delete_event " ,
G_CALLBACK ( window_delete_event_cb ) , NULL ) ;
g_signal_connect ( user_data - > dlg . save_voice_as_w , " destroy " ,
G_CALLBACK ( save_voice_as_destroy_cb ) , user_data ) ;
2004-05-26 03:49:24 +00:00
2003-09-24 07:48:12 +00:00
gtk_widget_show ( user_data - > dlg . save_voice_as_w ) ;
2004-05-26 03:49:24 +00:00
window_present ( user_data - > dlg . save_voice_as_w ) ;
2009-02-22 15:23:06 +00:00
if ( gtk_dialog_run ( GTK_DIALOG ( user_data - > dlg . save_voice_as_w ) ) = = GTK_RESPONSE_ACCEPT ) {
save_voice_as_ok_cb ( user_data - > dlg . save_voice_as_w , user_data - > dlg . save_voice_as_w ) ;
} else {
window_destroy ( user_data - > dlg . save_voice_as_w ) ;
}
2003-09-24 07:48:12 +00:00
}
/****************************************************************************/
/* when we are finished with redisection, we add the label for the statistic */
static void draw_stat ( user_data_t * user_data )
{
gchar label_max [ 200 ] ;
2003-09-25 19:35:14 +00:00
guint32 f_expected = ( user_data - > forward . statinfo . stop_seq_nr + user_data - > forward . statinfo . cycles * 65536 )
- user_data - > forward . statinfo . start_seq_nr + 1 ;
guint32 r_expected = ( user_data - > reversed . statinfo . stop_seq_nr + user_data - > reversed . statinfo . cycles * 65536 )
- user_data - > reversed . statinfo . start_seq_nr + 1 ;
gint32 f_lost = f_expected - user_data - > forward . statinfo . total_nr ;
gint32 r_lost = r_expected - user_data - > reversed . statinfo . total_nr ;
2004-10-01 07:14:50 +00:00
double f_perc , r_perc ;
if ( f_expected ) {
f_perc = ( double ) ( f_lost * 100 ) / ( double ) f_expected ;
} else {
f_perc = 0 ;
}
if ( r_expected ) {
r_perc = ( double ) ( r_lost * 100 ) / ( double ) r_expected ;
} else {
r_perc = 0 ;
2007-05-17 18:41:07 +00:00
}
2004-12-01 11:54:41 +00:00
g_snprintf ( label_max , 199 , " Max delta = %f sec at packet no. %u \n "
2004-10-01 07:14:50 +00:00
" Total RTP packets = %u (expected %u) Lost RTP packets = %d (%.2f%%) "
2003-09-24 07:48:12 +00:00
" Sequence errors = %u " ,
2004-12-01 11:54:41 +00:00
user_data - > forward . statinfo . max_delta , user_data - > forward . statinfo . max_nr ,
2004-01-24 01:15:24 +00:00
user_data - > forward . statinfo . total_nr ,
2004-10-01 07:14:50 +00:00
f_expected , f_lost , f_perc , user_data - > forward . statinfo . sequence ) ;
2003-09-24 07:48:12 +00:00
gtk_label_set_text ( GTK_LABEL ( user_data - > dlg . label_stats_fwd ) , label_max ) ;
2004-12-01 11:54:41 +00:00
g_snprintf ( label_max , 199 , " Max delta = %f sec at packet no. %u \n "
2004-10-01 07:14:50 +00:00
" Total RTP packets = %u (expected %u) Lost RTP packets = %d (%.2f%%) "
2003-09-24 07:48:12 +00:00
" Sequence errors = %u " ,
2004-12-01 11:54:41 +00:00
user_data - > reversed . statinfo . max_delta , user_data - > reversed . statinfo . max_nr ,
2004-01-24 01:15:24 +00:00
user_data - > reversed . statinfo . total_nr ,
2004-10-01 07:14:50 +00:00
r_expected , r_lost , r_perc , user_data - > reversed . statinfo . sequence ) ;
2003-09-24 07:48:12 +00:00
gtk_label_set_text ( GTK_LABEL ( user_data - > dlg . label_stats_rev ) , label_max ) ;
return ;
}
2004-01-23 00:29:52 +00:00
2003-09-24 07:48:12 +00:00
/****************************************************************************/
2009-02-20 17:13:44 +00:00
/* append a line to list */
static void add_to_list ( GtkWidget * list , user_data_t * user_data , guint32 number , guint16 seq_num ,
2004-12-01 11:54:41 +00:00
double delta , double jitter , double bandwidth , gchar * status , gboolean marker ,
2009-02-20 17:13:44 +00:00
gchar * timeStr , guint32 pkt_len , gchar * color_str , guint32 flags )
2003-09-24 07:48:12 +00:00
{
2009-02-20 17:13:44 +00:00
GtkListStore * list_store ;
2003-09-24 07:48:12 +00:00
2009-02-20 17:13:44 +00:00
if ( strcmp ( status , OK_TEXT ) ! = 0 ) {
user_data - > dlg . number_of_nok + + ;
2004-01-23 00:29:52 +00:00
}
2009-02-20 17:13:44 +00:00
list_store = GTK_LIST_STORE ( gtk_tree_view_get_model ( GTK_TREE_VIEW ( list ) ) ) ; /* Get store */
2009-02-26 16:46:00 +00:00
/* Creates a new row at position. iter will be changed to point to this new row.
* If position is larger than the number of rows on the list , then the new row will be appended to the list .
* The row will be filled with the values given to this function .
* :
* should generally be preferred when inserting rows in a sorted list store .
*/
2009-02-26 20:55:19 +00:00
# if GTK_CHECK_VERSION(2,6,0)
2009-02-26 16:46:00 +00:00
gtk_list_store_insert_with_values ( list_store , & user_data - > dlg . iter , G_MAXINT ,
2009-02-26 20:55:19 +00:00
# else
gtk_list_store_append ( list_store , & user_data - > dlg . iter ) ;
gtk_list_store_set ( list_store , & user_data - > dlg . iter ,
# endif
2009-02-20 17:13:44 +00:00
PACKET_COLUMN , number ,
SEQUENCE_COLUMN , seq_num ,
DELTA_COLUMN , delta ,
JITTER_COLUMN , jitter ,
IPBW_COLUMN , bandwidth ,
MARKER_COLUMN , marker ,
2009-02-26 20:55:19 +00:00
STATUS_COLUMN , ( char * ) status ,
DATE_COLUMN , ( char * ) timeStr ,
2009-02-20 17:13:44 +00:00
LENGTH_COLUMN , pkt_len ,
FOREGROUND_COLOR_COL , NULL ,
2009-02-26 20:55:19 +00:00
BACKGROUND_COLOR_COL , ( char * ) color_str ,
2009-02-20 17:13:44 +00:00
- 1 ) ;
2009-02-26 16:46:00 +00:00
2009-02-20 17:13:44 +00:00
if ( flags & STAT_FLAG_FIRST ) {
/* Set first row as active */
gtk_tree_selection_select_iter ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( list ) ) , & user_data - > dlg . iter ) ;
2004-01-23 00:29:52 +00:00
}
}
2009-02-20 17:13:44 +00:00
/****************************************************************************
* Functions needed to present values from the list
*/
2009-02-22 15:23:06 +00:00
2009-02-20 17:13:44 +00:00
/* Present boolean value */
void
2009-02-20 17:53:39 +00:00
rtp_boolean_data_func ( GtkTreeViewColumn * column _U_ ,
2009-02-20 17:13:44 +00:00
GtkCellRenderer * renderer ,
GtkTreeModel * model ,
GtkTreeIter * iter ,
gpointer user_data )
{
gboolean bool_val ;
gchar buf [ 20 ] ;
/* the col to get data from is in userdata */
gint bool_col = GPOINTER_TO_INT ( user_data ) ;
gtk_tree_model_get ( model , iter , bool_col , & bool_val , - 1 ) ;
switch ( bool_col ) {
case MARKER_COLUMN :
g_snprintf ( buf , sizeof ( buf ) , " %s " , bool_val ? " SET " : " " ) ;
break ;
default :
g_assert_not_reached ( ) ;
break ;
}
g_object_set ( renderer , " text " , buf , NULL ) ;
}
/* Create list */
2004-01-23 00:29:52 +00:00
static
2009-02-20 17:13:44 +00:00
GtkWidget * create_list ( user_data_t * user_data )
2004-01-23 00:29:52 +00:00
{
2009-02-20 17:13:44 +00:00
GtkListStore * list_store ;
GtkWidget * list ;
GtkTreeViewColumn * column ;
GtkCellRenderer * renderer ;
GtkTreeSortable * sortable ;
GtkTreeView * list_view ;
GtkTreeSelection * selection ;
/* Create the store */
list_store = gtk_list_store_new ( N_COLUMN , /* Total number of columns XXX*/
G_TYPE_UINT , /* Packet */
G_TYPE_UINT , /* Sequence */
G_TYPE_FLOAT , /* Delta(ms) */
G_TYPE_FLOAT , /* Jitter(ms) */
G_TYPE_FLOAT , /* IP BW(kbps) */
G_TYPE_BOOLEAN , /* Marker */
G_TYPE_STRING , /* Status */
G_TYPE_STRING , /* Date */
G_TYPE_UINT , /* Length */
G_TYPE_STRING , /* Foreground color */
G_TYPE_STRING ) ; /* Background color */
/* Create a view */
list = gtk_tree_view_new_with_model ( GTK_TREE_MODEL ( list_store ) ) ;
list_view = GTK_TREE_VIEW ( list ) ;
sortable = GTK_TREE_SORTABLE ( list_store ) ;
2009-02-26 07:55:09 +00:00
# if GTK_CHECK_VERSION(2,6,0)
/* Speed up the list display */
gtk_tree_view_set_fixed_height_mode ( list_view , TRUE ) ;
# endif
2009-02-20 17:13:44 +00:00
/* Setup the sortable columns */
gtk_tree_sortable_set_sort_column_id ( sortable , PACKET_COLUMN , GTK_SORT_ASCENDING ) ;
gtk_tree_view_set_headers_clickable ( list_view , FALSE ) ;
/* The view now holds a reference. We can get rid of our own reference */
g_object_unref ( G_OBJECT ( list_store ) ) ;
/*
* Create the first column packet , associating the " text " attribute of the
* cell_renderer to the first column of the model
*/
renderer = gtk_cell_renderer_text_new ( ) ;
column = gtk_tree_view_column_new_with_attributes ( " Packet " , renderer ,
" text " , PACKET_COLUMN ,
" foreground " , FOREGROUND_COLOR_COL ,
" background " , BACKGROUND_COLOR_COL ,
NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , PACKET_COLUMN ) ;
gtk_tree_view_column_set_resizable ( column , TRUE ) ;
2009-02-26 07:55:09 +00:00
gtk_tree_view_column_set_sizing ( column , GTK_TREE_VIEW_COLUMN_FIXED ) ;
gtk_tree_view_column_set_min_width ( column , 100 ) ;
2009-02-20 17:13:44 +00:00
/* Add the column to the view. */
gtk_tree_view_append_column ( list_view , column ) ;
/* Second column.. Sequence. */
renderer = gtk_cell_renderer_text_new ( ) ;
column = gtk_tree_view_column_new_with_attributes ( " Sequence " , renderer ,
" text " , SEQUENCE_COLUMN ,
" foreground " , FOREGROUND_COLOR_COL ,
" background " , BACKGROUND_COLOR_COL ,
NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , SEQUENCE_COLUMN ) ;
gtk_tree_view_column_set_resizable ( column , TRUE ) ;
2009-02-26 07:55:09 +00:00
gtk_tree_view_column_set_sizing ( column , GTK_TREE_VIEW_COLUMN_FIXED ) ;
gtk_tree_view_column_set_min_width ( column , 100 ) ;
2009-02-20 17:13:44 +00:00
gtk_tree_view_append_column ( list_view , column ) ;
/* Third column.. Delta(ms). */
renderer = gtk_cell_renderer_text_new ( ) ;
column = gtk_tree_view_column_new_with_attributes ( " Delta(ms) " , renderer ,
" text " , DELTA_COLUMN ,
" foreground " , FOREGROUND_COLOR_COL ,
" background " , BACKGROUND_COLOR_COL ,
NULL ) ;
2009-03-06 17:16:56 +00:00
gtk_tree_view_column_set_cell_data_func ( column , renderer , float_data_func ,
2009-02-20 17:13:44 +00:00
GINT_TO_POINTER ( DELTA_COLUMN ) , NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , DELTA_COLUMN ) ;
gtk_tree_view_column_set_resizable ( column , TRUE ) ;
2009-02-26 07:55:09 +00:00
gtk_tree_view_column_set_sizing ( column , GTK_TREE_VIEW_COLUMN_FIXED ) ;
gtk_tree_view_column_set_min_width ( column , 100 ) ;
2009-02-20 17:13:44 +00:00
gtk_tree_view_append_column ( list_view , column ) ;
/* Forth column.. Jitter(ms). */
renderer = gtk_cell_renderer_text_new ( ) ;
column = gtk_tree_view_column_new_with_attributes ( " Jitter(ms) " , renderer ,
" text " , JITTER_COLUMN ,
" foreground " , FOREGROUND_COLOR_COL ,
" background " , BACKGROUND_COLOR_COL ,
NULL ) ;
2009-03-06 17:16:56 +00:00
gtk_tree_view_column_set_cell_data_func ( column , renderer , float_data_func ,
2009-02-20 17:13:44 +00:00
GINT_TO_POINTER ( JITTER_COLUMN ) , NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , JITTER_COLUMN ) ;
gtk_tree_view_column_set_resizable ( column , TRUE ) ;
2009-02-26 07:55:09 +00:00
gtk_tree_view_column_set_sizing ( column , GTK_TREE_VIEW_COLUMN_FIXED ) ;
gtk_tree_view_column_set_min_width ( column , 100 ) ;
2009-02-20 17:13:44 +00:00
gtk_tree_view_append_column ( list_view , column ) ;
/* Fifth column.. IP BW(kbps). */
renderer = gtk_cell_renderer_text_new ( ) ;
column = gtk_tree_view_column_new_with_attributes ( " IP BW(kbps) " , renderer ,
" text " , IPBW_COLUMN ,
" foreground " , FOREGROUND_COLOR_COL ,
" background " , BACKGROUND_COLOR_COL ,
NULL ) ;
2009-03-06 17:16:56 +00:00
gtk_tree_view_column_set_cell_data_func ( column , renderer , float_data_func ,
2009-02-20 17:13:44 +00:00
GINT_TO_POINTER ( IPBW_COLUMN ) , NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , IPBW_COLUMN ) ;
gtk_tree_view_column_set_resizable ( column , TRUE ) ;
2009-02-26 07:55:09 +00:00
gtk_tree_view_column_set_sizing ( column , GTK_TREE_VIEW_COLUMN_FIXED ) ;
gtk_tree_view_column_set_min_width ( column , 100 ) ;
2009-02-20 17:13:44 +00:00
gtk_tree_view_append_column ( list_view , column ) ;
/* Sixth column.. Marker. */
renderer = gtk_cell_renderer_text_new ( ) ;
column = gtk_tree_view_column_new_with_attributes ( " Marker " , renderer ,
" text " , MARKER_COLUMN ,
" foreground " , FOREGROUND_COLOR_COL ,
" background " , BACKGROUND_COLOR_COL ,
NULL ) ;
gtk_tree_view_column_set_cell_data_func ( column , renderer , rtp_boolean_data_func ,
GINT_TO_POINTER ( MARKER_COLUMN ) , NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , MARKER_COLUMN ) ;
gtk_tree_view_column_set_resizable ( column , TRUE ) ;
2009-02-26 07:55:09 +00:00
gtk_tree_view_column_set_sizing ( column , GTK_TREE_VIEW_COLUMN_FIXED ) ;
gtk_tree_view_column_set_min_width ( column , 75 ) ;
2009-02-20 17:13:44 +00:00
gtk_tree_view_append_column ( list_view , column ) ;
/* Seventh column.. Status. */
renderer = gtk_cell_renderer_text_new ( ) ;
column = gtk_tree_view_column_new_with_attributes ( " Status " , renderer ,
" text " , STATUS_COLUMN ,
" foreground " , FOREGROUND_COLOR_COL ,
" background " , BACKGROUND_COLOR_COL ,
NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , STATUS_COLUMN ) ;
gtk_tree_view_column_set_resizable ( column , TRUE ) ;
2009-02-26 07:55:09 +00:00
gtk_tree_view_column_set_sizing ( column , GTK_TREE_VIEW_COLUMN_FIXED ) ;
gtk_tree_view_column_set_min_width ( column , 100 ) ;
2009-02-20 17:13:44 +00:00
gtk_tree_view_append_column ( list_view , column ) ;
/* Now enable the sorting of each column */
gtk_tree_view_set_rules_hint ( GTK_TREE_VIEW ( list_view ) , TRUE ) ;
gtk_tree_view_set_headers_clickable ( GTK_TREE_VIEW ( list_view ) , TRUE ) ;
/* Setup the selection handler */
selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( list ) ) ;
gtk_tree_selection_set_mode ( selection , GTK_SELECTION_SINGLE ) ;
g_signal_connect ( G_OBJECT ( selection ) , " changed " , /* select_row */
G_CALLBACK ( on_list_select_row ) ,
user_data ) ;
return list ;
2004-01-23 00:29:52 +00:00
}
2003-09-24 07:48:12 +00:00
/****************************************************************************/
/* Create the dialog box with all widgets */
2005-08-20 14:02:00 +00:00
static void create_rtp_dialog ( user_data_t * user_data )
2003-09-24 07:48:12 +00:00
{
GtkWidget * window = NULL ;
2009-02-20 17:13:44 +00:00
GtkWidget * list_fwd ;
GtkWidget * list_rev ;
2003-09-24 07:48:12 +00:00
GtkWidget * label_stats_fwd ;
GtkWidget * label_stats_rev ;
GtkWidget * notebook ;
2004-01-23 00:29:52 +00:00
GtkWidget * main_vb , * page , * page_r ;
GtkWidget * label ;
2003-09-24 07:48:12 +00:00
GtkWidget * scrolled_window , * scrolled_window_r /*, *frame, *text, *label4, *page_help*/ ;
2004-01-23 00:29:52 +00:00
GtkWidget * box4 , * voice_bt , * refresh_bt , * goto_bt , * close_bt , * csv_bt , * next_bt ;
2003-09-24 07:48:12 +00:00
# ifdef USE_CONVERSATION_GRAPH
GtkWidget * graph_bt ;
# endif
2004-10-01 07:14:50 +00:00
GtkWidget * graph_bt ;
2003-09-24 07:48:12 +00:00
gchar label_forward [ 150 ] ;
2009-02-20 17:13:44 +00:00
gchar label_forward_tree [ 150 ] ;
2003-09-24 07:48:12 +00:00
gchar label_reverse [ 150 ] ;
gchar str_ip_src [ 16 ] ;
gchar str_ip_dst [ 16 ] ;
2007-05-17 18:41:07 +00:00
2006-05-22 07:29:40 +00:00
window = window_new ( GTK_WINDOW_TOPLEVEL , " Wireshark: RTP Stream Analysis " ) ;
2004-10-06 07:21:05 +00:00
gtk_window_set_default_size ( GTK_WINDOW ( window ) , 700 , 400 ) ;
2003-09-24 07:48:12 +00:00
/* Container for each row of widgets */
2004-01-24 01:15:24 +00:00
main_vb = gtk_vbox_new ( FALSE , 2 ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( main_vb ) , 2 ) ;
2003-09-24 07:48:12 +00:00
gtk_container_add ( GTK_CONTAINER ( window ) , main_vb ) ;
gtk_widget_show ( main_vb ) ;
/* Notebooks... */
2008-02-29 13:33:37 +00:00
g_strlcpy ( str_ip_src , get_addr_name ( & ( user_data - > ip_src_fwd ) ) , 16 ) ;
g_strlcpy ( str_ip_dst , get_addr_name ( & ( user_data - > ip_dst_fwd ) ) , 16 ) ;
2003-09-24 07:48:12 +00:00
2007-05-17 18:41:07 +00:00
g_snprintf ( label_forward , 149 ,
2007-05-31 18:41:25 +00:00
" Analysing stream from %s port %u to %s port %u SSRC = 0x%X " ,
2003-09-24 07:48:12 +00:00
str_ip_src , user_data - > port_src_fwd , str_ip_dst , user_data - > port_dst_fwd , user_data - > ssrc_fwd ) ;
2009-02-20 17:13:44 +00:00
g_snprintf ( label_forward_tree , 149 ,
" Analysing stream from %s port %u to %s port %u SSRC = 0x%X " ,
str_ip_src , user_data - > port_src_fwd , str_ip_dst , user_data - > port_dst_fwd , user_data - > ssrc_fwd ) ;
2004-12-01 11:54:41 +00:00
2008-02-29 13:33:37 +00:00
g_strlcpy ( str_ip_src , get_addr_name ( & ( user_data - > ip_src_rev ) ) , 16 ) ;
g_strlcpy ( str_ip_dst , get_addr_name ( & ( user_data - > ip_dst_rev ) ) , 16 ) ;
2003-09-24 07:48:12 +00:00
g_snprintf ( label_reverse , 149 ,
2007-05-31 18:41:25 +00:00
" Analysing stream from %s port %u to %s port %u SSRC = 0x%X " ,
2003-09-24 07:48:12 +00:00
str_ip_src , user_data - > port_src_rev , str_ip_dst , user_data - > port_dst_rev , user_data - > ssrc_rev ) ;
/* Start a notebook for flipping between sets of changes */
notebook = gtk_notebook_new ( ) ;
gtk_container_add ( GTK_CONTAINER ( main_vb ) , notebook ) ;
2008-04-11 16:04:54 +00:00
g_object_set_data ( G_OBJECT ( window ) , " notebook " , notebook ) ;
2004-10-01 07:14:50 +00:00
2008-05-22 15:46:27 +00:00
user_data - > dlg . notebook_signal_id =
2008-04-11 23:16:06 +00:00
g_signal_connect ( notebook , " switch_page " , G_CALLBACK ( on_notebook_switch_page ) , user_data ) ;
2003-09-24 07:48:12 +00:00
/* page for forward connection */
2004-01-24 01:15:24 +00:00
page = gtk_vbox_new ( FALSE , 8 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( page ) , 8 ) ;
2003-09-24 07:48:12 +00:00
/* direction label */
2004-01-23 00:29:52 +00:00
label = gtk_label_new ( label_forward ) ;
gtk_box_pack_start ( GTK_BOX ( page ) , label , FALSE , FALSE , 0 ) ;
2003-09-24 07:48:12 +00:00
/* place for some statistics */
2004-01-24 01:15:24 +00:00
label_stats_fwd = gtk_label_new ( " \n " ) ;
gtk_box_pack_end ( GTK_BOX ( page ) , label_stats_fwd , FALSE , FALSE , 0 ) ;
2003-09-24 07:48:12 +00:00
2004-01-23 00:29:52 +00:00
/* scrolled window */
2004-02-06 19:19:12 +00:00
scrolled_window = scrolled_window_new ( NULL , NULL ) ;
2004-01-23 00:29:52 +00:00
2009-02-20 17:13:44 +00:00
/* packet list */
list_fwd = create_list ( user_data ) ;
gtk_widget_show ( list_fwd ) ;
gtk_container_add ( GTK_CONTAINER ( scrolled_window ) , list_fwd ) ;
2003-09-24 07:48:12 +00:00
gtk_box_pack_start ( GTK_BOX ( page ) , scrolled_window , TRUE , TRUE , 0 ) ;
2004-01-23 00:29:52 +00:00
gtk_widget_show ( scrolled_window ) ;
2003-09-24 07:48:12 +00:00
2004-01-23 00:29:52 +00:00
/* tab */
label = gtk_label_new ( " Forward Direction " ) ;
2003-09-24 07:48:12 +00:00
gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ) , page , label ) ;
/* same page for reversed connection */
2004-01-24 01:15:24 +00:00
page_r = gtk_vbox_new ( FALSE , 8 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( page_r ) , 8 ) ;
2004-01-23 00:29:52 +00:00
label = gtk_label_new ( label_reverse ) ;
gtk_box_pack_start ( GTK_BOX ( page_r ) , label , FALSE , FALSE , 0 ) ;
2004-01-24 01:15:24 +00:00
label_stats_rev = gtk_label_new ( " \n " ) ;
gtk_box_pack_end ( GTK_BOX ( page_r ) , label_stats_rev , FALSE , FALSE , 0 ) ;
2004-01-23 00:29:52 +00:00
2004-02-06 19:19:12 +00:00
scrolled_window_r = scrolled_window_new ( NULL , NULL ) ;
2003-09-24 07:48:12 +00:00
2009-02-20 17:13:44 +00:00
list_rev = create_list ( user_data ) ;
gtk_widget_show ( list_rev ) ;
gtk_container_add ( GTK_CONTAINER ( scrolled_window_r ) , list_rev ) ;
2003-09-24 07:48:12 +00:00
gtk_box_pack_start ( GTK_BOX ( page_r ) , scrolled_window_r , TRUE , TRUE , 0 ) ;
2004-01-23 00:29:52 +00:00
gtk_widget_show ( scrolled_window_r ) ;
label = gtk_label_new ( " Reversed Direction " ) ;
gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ) , page_r , label ) ;
2003-09-24 07:48:12 +00:00
/* page for help&about or future
page_help = gtk_hbox_new ( FALSE , 5 ) ;
2004-01-23 00:29:52 +00:00
label = gtk_label_new ( " Future " ) ;
gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ) , page_help , label ) ;
2003-09-24 07:48:12 +00:00
frame = gtk_frame_new ( " " ) ;
2004-12-01 11:54:41 +00:00
text = gtk_label_new ( " \n \n Maybe some more statistics: delta and jitter distribution,... " ) ;
2003-09-24 07:48:12 +00:00
gtk_label_set_justify ( GTK_LABEL ( text ) , GTK_JUSTIFY_LEFT ) ;
gtk_container_add ( GTK_CONTAINER ( frame ) , text ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( frame ) , 20 ) ;
gtk_box_pack_start ( GTK_BOX ( page_help ) , frame , TRUE , TRUE , 0 ) ;
*/
/* show all notebooks */
gtk_widget_show_all ( notebook ) ;
/* buttons */
box4 = gtk_hbutton_box_new ( ) ;
gtk_box_pack_start ( GTK_BOX ( main_vb ) , box4 , FALSE , FALSE , 0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( box4 ) , 10 ) ;
gtk_button_box_set_layout ( GTK_BUTTON_BOX ( box4 ) , GTK_BUTTONBOX_EDGE ) ;
2008-07-08 02:43:40 +00:00
gtk_box_set_spacing ( GTK_BOX ( box4 ) , 0 ) ;
2003-09-24 07:48:12 +00:00
gtk_button_box_set_child_ipadding ( GTK_BUTTON_BOX ( box4 ) , 4 , 0 ) ;
gtk_widget_show ( box4 ) ;
voice_bt = gtk_button_new_with_label ( " Save payload... " ) ;
gtk_container_add ( GTK_CONTAINER ( box4 ) , voice_bt ) ;
gtk_widget_show ( voice_bt ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( voice_bt , " clicked " , G_CALLBACK ( on_save_bt_clicked ) , user_data ) ;
2003-09-24 07:48:12 +00:00
csv_bt = gtk_button_new_with_label ( " Save as CSV... " ) ;
gtk_container_add ( GTK_CONTAINER ( box4 ) , csv_bt ) ;
gtk_widget_show ( csv_bt ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( csv_bt , " clicked " , G_CALLBACK ( save_csv_as_cb ) , user_data ) ;
2004-01-23 00:29:52 +00:00
2008-04-11 18:58:19 +00:00
refresh_bt = gtk_button_new_from_stock ( GTK_STOCK_REFRESH ) ;
2003-09-24 07:48:12 +00:00
gtk_container_add ( GTK_CONTAINER ( box4 ) , refresh_bt ) ;
gtk_widget_show ( refresh_bt ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( refresh_bt , " clicked " , G_CALLBACK ( on_refresh_bt_clicked ) , user_data ) ;
2004-01-23 00:29:52 +00:00
2008-04-11 18:58:19 +00:00
goto_bt = gtk_button_new_from_stock ( GTK_STOCK_JUMP_TO ) ;
2003-09-24 07:48:12 +00:00
gtk_container_add ( GTK_CONTAINER ( box4 ) , goto_bt ) ;
gtk_widget_show ( goto_bt ) ;
2009-02-20 17:13:44 +00:00
g_signal_connect ( goto_bt , " clicked " , G_CALLBACK ( on_goto_bt_clicked_lst ) , user_data ) ;
2003-09-24 07:48:12 +00:00
2009-02-20 17:13:44 +00:00
graph_bt = gtk_button_new_with_label ( " Graph " ) ;
2004-10-01 07:14:50 +00:00
gtk_container_add ( GTK_CONTAINER ( box4 ) , graph_bt ) ;
gtk_widget_show ( graph_bt ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( graph_bt , " clicked " , G_CALLBACK ( on_graph_bt_clicked ) , user_data ) ;
2004-10-01 07:14:50 +00:00
2003-09-24 07:48:12 +00:00
# ifdef USE_CONVERSATION_GRAPH
graph_bt = gtk_button_new_with_label ( " Graph " ) ;
gtk_container_add ( GTK_CONTAINER ( box4 ) , graph_bt ) ;
gtk_widget_show ( graph_bt ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( graph_bt , " clicked " , G_CALLBACK ( on_graph_bt_clicked ) , user_data ) ;
2003-09-24 07:48:12 +00:00
# endif
2004-01-23 00:29:52 +00:00
next_bt = gtk_button_new_with_label ( " Next non-Ok " ) ;
2003-09-25 19:35:14 +00:00
gtk_container_add ( GTK_CONTAINER ( box4 ) , next_bt ) ;
gtk_widget_show ( next_bt ) ;
2009-02-20 17:13:44 +00:00
g_signal_connect ( next_bt , " clicked " , G_CALLBACK ( on_next_bt_clicked_list ) , user_data ) ;
2003-09-25 19:35:14 +00:00
2008-04-11 18:58:19 +00:00
close_bt = gtk_button_new_from_stock ( GTK_STOCK_CLOSE ) ;
2003-09-24 07:48:12 +00:00
gtk_container_add ( GTK_CONTAINER ( box4 ) , close_bt ) ;
2004-05-27 19:59:50 +00:00
GTK_WIDGET_SET_FLAGS ( close_bt , GTK_CAN_DEFAULT ) ;
2003-09-24 07:48:12 +00:00
gtk_widget_show ( close_bt ) ;
2004-05-23 23:24:07 +00:00
window_set_cancel_button ( window , close_bt , window_cancel_button_cb ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( window , " delete_event " , G_CALLBACK ( window_delete_event_cb ) , NULL ) ;
g_signal_connect ( window , " destroy " , G_CALLBACK ( on_destroy ) , user_data ) ;
2003-09-24 07:48:12 +00:00
2004-05-23 23:24:07 +00:00
gtk_widget_show ( window ) ;
window_present ( window ) ;
2003-09-24 07:48:12 +00:00
2004-01-23 00:29:52 +00:00
/* some widget references need to be saved for outside use */
2003-09-24 07:48:12 +00:00
user_data - > dlg . window = window ;
2009-02-20 17:13:44 +00:00
user_data - > dlg . list_fwd = list_fwd ;
user_data - > dlg . list_rev = list_rev ;
2003-09-24 07:48:12 +00:00
user_data - > dlg . label_stats_fwd = label_stats_fwd ;
user_data - > dlg . label_stats_rev = label_stats_rev ;
user_data - > dlg . notebook = notebook ;
2009-02-20 17:13:44 +00:00
user_data - > dlg . selected_list = list_fwd ;
user_data - > dlg . number_of_nok = 0 ;
/*
* select the initial row
*/
gtk_widget_grab_focus ( list_fwd ) ;
2003-09-24 07:48:12 +00:00
}
/****************************************************************************/
2003-12-04 10:59:34 +00:00
static gboolean process_node ( proto_node * ptree_node , header_field_info * hfinformation ,
2005-08-06 14:03:14 +00:00
const gchar * proto_field , guint32 * p_result )
2003-09-24 07:48:12 +00:00
{
field_info * finfo ;
2003-12-04 10:59:34 +00:00
proto_node * proto_sibling_node ;
2003-09-24 07:48:12 +00:00
header_field_info * hfssrc ;
ipv4_addr * ipv4 ;
finfo = PITEM_FINFO ( ptree_node ) ;
2003-12-03 09:28:26 +00:00
if ( hfinformation = = ( finfo - > hfinfo ) ) {
2004-01-23 00:29:52 +00:00
hfssrc = proto_registrar_get_byname ( proto_field ) ;
2003-09-24 07:48:12 +00:00
if ( hfssrc = = NULL )
return FALSE ;
2007-05-17 18:41:07 +00:00
for ( ptree_node = ptree_node - > first_child ; ptree_node ! = NULL ;
2003-12-04 10:59:34 +00:00
ptree_node = ptree_node - > next ) {
2003-09-24 07:48:12 +00:00
finfo = PITEM_FINFO ( ptree_node ) ;
2003-12-03 09:28:26 +00:00
if ( hfssrc = = finfo - > hfinfo ) {
2003-09-24 07:48:12 +00:00
if ( hfinformation - > type = = FT_IPv4 ) {
2003-12-02 21:15:49 +00:00
ipv4 = fvalue_get ( & finfo - > value ) ;
2003-09-24 07:48:12 +00:00
* p_result = ipv4_get_net_order_addr ( ipv4 ) ;
}
else {
2007-01-18 11:02:26 +00:00
* p_result = fvalue_get_uinteger ( & finfo - > value ) ;
2003-09-24 07:48:12 +00:00
}
return TRUE ;
}
}
2006-03-09 12:16:53 +00:00
if ( ! ptree_node )
return FALSE ;
2003-09-24 07:48:12 +00:00
}
2003-12-04 10:59:34 +00:00
proto_sibling_node = ptree_node - > next ;
2003-09-24 07:48:12 +00:00
if ( proto_sibling_node ) {
return process_node ( proto_sibling_node , hfinformation , proto_field , p_result ) ;
}
else
return FALSE ;
}
/****************************************************************************/
static gboolean get_int_value_from_proto_tree ( proto_tree * protocol_tree ,
2005-08-06 14:03:14 +00:00
const gchar * proto_name ,
const gchar * proto_field ,
guint32 * p_result )
2003-09-24 07:48:12 +00:00
{
2003-12-04 10:59:34 +00:00
proto_node * ptree_node ;
2003-09-24 07:48:12 +00:00
header_field_info * hfinformation ;
2004-01-23 00:29:52 +00:00
hfinformation = proto_registrar_get_byname ( proto_name ) ;
2003-09-24 07:48:12 +00:00
if ( hfinformation = = NULL )
return FALSE ;
2003-12-04 10:59:34 +00:00
ptree_node = ( ( proto_node * ) protocol_tree ) - > first_child ;
2003-09-24 07:48:12 +00:00
if ( ! ptree_node )
return FALSE ;
return process_node ( ptree_node , hfinformation , proto_field , p_result ) ;
}
/****************************************************************************/
void rtp_analysis (
2004-12-01 11:54:41 +00:00
address * ip_src_fwd ,
2003-09-24 07:48:12 +00:00
guint16 port_src_fwd ,
2004-12-01 11:54:41 +00:00
address * ip_dst_fwd ,
2003-09-24 07:48:12 +00:00
guint16 port_dst_fwd ,
guint32 ssrc_fwd ,
2004-12-01 11:54:41 +00:00
address * ip_src_rev ,
2003-09-24 07:48:12 +00:00
guint16 port_src_rev ,
2004-12-01 11:54:41 +00:00
address * ip_dst_rev ,
2003-09-24 07:48:12 +00:00
guint16 port_dst_rev ,
guint32 ssrc_rev
)
{
user_data_t * user_data ;
2004-01-27 18:05:32 +00:00
int fd ;
2004-10-01 07:14:50 +00:00
int i ;
static color_t col [ MAX_GRAPHS ] = {
{ 0 , 0x0000 , 0x0000 , 0x0000 } ,
{ 0 , 0xffff , 0x0000 , 0x0000 } ,
{ 0 , 0x0000 , 0xffff , 0x0000 } ,
{ 0 , 0x0000 , 0x0000 , 0xffff }
} ;
2004-12-01 11:54:41 +00:00
2004-01-23 00:29:52 +00:00
/* init */
2003-09-24 07:48:12 +00:00
user_data = g_malloc ( sizeof ( user_data_t ) ) ;
2004-12-01 11:54:41 +00:00
COPY_ADDRESS ( & ( user_data - > ip_src_fwd ) , ip_src_fwd ) ;
2003-09-24 07:48:12 +00:00
user_data - > port_src_fwd = port_src_fwd ;
2004-12-01 11:54:41 +00:00
COPY_ADDRESS ( & ( user_data - > ip_dst_fwd ) , ip_dst_fwd ) ;
2003-09-24 07:48:12 +00:00
user_data - > port_dst_fwd = port_dst_fwd ;
user_data - > ssrc_fwd = ssrc_fwd ;
2004-12-01 11:54:41 +00:00
COPY_ADDRESS ( & ( user_data - > ip_src_rev ) , ip_src_rev ) ;
2003-09-24 07:48:12 +00:00
user_data - > port_src_rev = port_src_rev ;
2004-12-01 11:54:41 +00:00
COPY_ADDRESS ( & ( user_data - > ip_dst_rev ) , ip_dst_rev ) ;
2003-09-24 07:48:12 +00:00
user_data - > port_dst_rev = port_dst_rev ;
user_data - > ssrc_rev = ssrc_rev ;
2004-12-01 11:54:41 +00:00
2003-09-24 07:48:12 +00:00
/* file names for storing sound data */
2004-01-27 18:05:32 +00:00
/*XXX: check for errors*/
fd = create_tempfile ( user_data - > f_tempname , sizeof ( user_data - > f_tempname ) ,
" ether_rtp_f " ) ;
2008-05-22 15:46:27 +00:00
ws_close ( fd ) ;
2004-01-27 18:05:32 +00:00
fd = create_tempfile ( user_data - > r_tempname , sizeof ( user_data - > r_tempname ) ,
" ether_rtp_r " ) ;
2008-05-22 15:46:27 +00:00
ws_close ( fd ) ;
2003-09-25 19:35:14 +00:00
user_data - > forward . saveinfo . fp = NULL ;
user_data - > reversed . saveinfo . fp = NULL ;
2003-09-24 07:48:12 +00:00
user_data - > dlg . save_voice_as_w = NULL ;
user_data - > dlg . save_csv_as_w = NULL ;
2009-02-20 17:13:44 +00:00
user_data - > dlg . dialog_graph . window = NULL ;
2004-10-01 07:14:50 +00:00
2003-09-24 07:48:12 +00:00
# ifdef USE_CONVERSATION_GRAPH
user_data - > dlg . graph_window = NULL ;
user_data - > series_fwd . value_pairs = NULL ;
user_data - > series_rev . value_pairs = NULL ;
# endif
2004-10-01 07:14:50 +00:00
/* init dialog_graph */
user_data - > dlg . dialog_graph . needs_redraw = TRUE ;
user_data - > dlg . dialog_graph . interval = tick_interval_values [ DEFAULT_TICK_VALUE ] ;
user_data - > dlg . dialog_graph . draw_area = NULL ;
user_data - > dlg . dialog_graph . pixmap = NULL ;
user_data - > dlg . dialog_graph . scrollbar = NULL ;
user_data - > dlg . dialog_graph . scrollbar_adjustment = NULL ;
user_data - > dlg . dialog_graph . pixmap_width = 500 ;
user_data - > dlg . dialog_graph . pixmap_height = 200 ;
user_data - > dlg . dialog_graph . pixels_per_tick = pixels_per_tick [ DEFAULT_PIXELS_PER_TICK ] ;
user_data - > dlg . dialog_graph . max_y_units = AUTO_MAX_YSCALE ;
user_data - > dlg . dialog_graph . last_interval = 0xffffffff ;
user_data - > dlg . dialog_graph . max_interval = 0 ;
user_data - > dlg . dialog_graph . num_items = 0 ;
user_data - > dlg . dialog_graph . start_time = - 1 ;
for ( i = 0 ; i < MAX_GRAPHS ; i + + ) {
user_data - > dlg . dialog_graph . graph [ i ] . gc = NULL ;
user_data - > dlg . dialog_graph . graph [ i ] . color . pixel = 0 ;
user_data - > dlg . dialog_graph . graph [ i ] . color . red = col [ i ] . red ;
user_data - > dlg . dialog_graph . graph [ i ] . color . green = col [ i ] . green ;
user_data - > dlg . dialog_graph . graph [ i ] . color . blue = col [ i ] . blue ;
user_data - > dlg . dialog_graph . graph [ i ] . display = TRUE ;
user_data - > dlg . dialog_graph . graph [ i ] . display_button = NULL ;
user_data - > dlg . dialog_graph . graph [ i ] . ud = user_data ;
}
2004-01-23 00:29:52 +00:00
/* create the dialog box */
create_rtp_dialog ( user_data ) ;
2004-01-19 23:35:32 +00:00
2004-01-23 00:29:52 +00:00
/* proceed as if the Refresh button would have been pressed */
on_refresh_bt_clicked ( NULL , user_data ) ;
2003-09-24 07:48:12 +00:00
}
/****************************************************************************/
/* entry point from main menu */
2007-05-17 18:41:07 +00:00
static void rtp_analysis_cb ( GtkWidget * w _U_ , gpointer data _U_ )
2003-09-24 07:48:12 +00:00
{
2004-12-01 11:54:41 +00:00
address ip_src_fwd ;
2003-09-24 07:48:12 +00:00
guint16 port_src_fwd ;
2004-12-01 11:54:41 +00:00
address ip_dst_fwd ;
2003-09-24 07:48:12 +00:00
guint16 port_dst_fwd ;
guint32 ssrc_fwd = 0 ;
2004-12-01 11:54:41 +00:00
address ip_src_rev ;
2003-09-24 07:48:12 +00:00
guint16 port_src_rev ;
2004-12-01 11:54:41 +00:00
address ip_dst_rev ;
2003-09-24 07:48:12 +00:00
guint16 port_dst_rev ;
guint32 ssrc_rev = 0 ;
2004-10-17 22:14:47 +00:00
unsigned int version_fwd ;
2003-09-24 07:48:12 +00:00
gchar filter_text [ 256 ] ;
dfilter_t * sfcode ;
capture_file * cf ;
epan_dissect_t * edt ;
gint err ;
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
gchar * err_info ;
2003-09-24 07:48:12 +00:00
gboolean frame_matched ;
frame_data * fdata ;
GList * strinfo_list ;
GList * filtered_list = NULL ;
rtp_stream_info_t * strinfo ;
guint nfound ;
/* Try to compile the filter. */
2008-02-29 13:33:37 +00:00
g_strlcpy ( filter_text , " rtp && rtp.version && rtp.ssrc && (ip || ipv6) " , 256 ) ;
2003-09-24 07:48:12 +00:00
if ( ! dfilter_compile ( filter_text , & sfcode ) ) {
2008-10-31 09:53:56 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , dfilter_error_msg ) ;
2003-09-24 07:48:12 +00:00
return ;
}
/* we load the current file into cf variable */
cf = & cfile ;
fdata = cf - > current_frame ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/* we are on the selected frame now */
if ( fdata = = NULL )
return ; /* if we exit here it's an error */
/* dissect the current frame */
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
if ( ! wtap_seek_read ( cf - > wth , fdata - > file_off , & cf - > pseudo_header ,
cf - > pd , fdata - > cap_len , & err , & err_info ) ) {
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
cf_read_error_message ( err , err_info ) , cf - > filename ) ;
2003-09-24 07:48:12 +00:00
return ;
}
edt = epan_dissect_new ( TRUE , FALSE ) ;
epan_dissect_prime_dfilter ( edt , sfcode ) ;
2005-04-07 12:00:03 +00:00
epan_dissect_run ( edt , & cf - > pseudo_header , cf - > pd , fdata , NULL ) ;
2003-09-24 07:48:12 +00:00
frame_matched = dfilter_apply_edt ( sfcode , edt ) ;
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/* if it is not an rtp frame, show the rtpstream dialog */
frame_matched = dfilter_apply_edt ( sfcode , edt ) ;
if ( frame_matched ! = 1 ) {
epan_dissect_free ( edt ) ;
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2004-01-31 03:22:42 +00:00
" You didn't choose a RTP packet! " ) ;
2003-09-24 07:48:12 +00:00
return ;
}
/* ok, it is a RTP frame, so let's get the ip and port values */
2004-12-01 11:54:41 +00:00
COPY_ADDRESS ( & ( ip_src_fwd ) , & ( edt - > pi . src ) )
COPY_ADDRESS ( & ( ip_dst_fwd ) , & ( edt - > pi . dst ) )
2003-09-24 07:48:12 +00:00
port_src_fwd = edt - > pi . srcport ;
port_dst_fwd = edt - > pi . destport ;
/* assume the inverse ip/port combination for the reverse direction */
2004-12-01 11:54:41 +00:00
COPY_ADDRESS ( & ( ip_src_rev ) , & ( edt - > pi . dst ) )
COPY_ADDRESS ( & ( ip_dst_rev ) , & ( edt - > pi . src ) )
2003-09-24 07:48:12 +00:00
port_src_rev = edt - > pi . destport ;
port_dst_rev = edt - > pi . srcport ;
2004-10-17 22:14:47 +00:00
/* check if it is RTP Version 2 */
if ( ! get_int_value_from_proto_tree ( edt - > tree , " rtp " , " rtp.version " , & version_fwd ) | | version_fwd ! = 2 ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2004-12-29 01:08:20 +00:00
" RTP Version != 2 isn't supported! " ) ;
2004-10-17 22:14:47 +00:00
return ;
}
2007-05-17 18:41:07 +00:00
2003-09-24 07:48:12 +00:00
/* now we need the SSRC value of the current frame */
if ( ! get_int_value_from_proto_tree ( edt - > tree , " rtp " , " rtp.ssrc " , & ssrc_fwd ) ) {
2004-02-12 22:24:28 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
2004-01-31 03:22:42 +00:00
" SSRC value couldn't be found! " ) ;
2003-09-24 07:48:12 +00:00
return ;
}
2004-10-01 07:14:50 +00:00
/* Scan for rtpstream */
rtpstream_scan ( ) ;
2003-09-24 07:48:12 +00:00
/* search for reversed direction in the global rtp streams list */
nfound = 0 ;
strinfo_list = g_list_first ( rtpstream_get_info ( ) - > strinfo_list ) ;
while ( strinfo_list )
{
strinfo = ( rtp_stream_info_t * ) ( strinfo_list - > data ) ;
2004-12-01 11:54:41 +00:00
if ( ADDRESSES_EQUAL ( & ( strinfo - > src_addr ) , & ( ip_src_fwd ) )
2003-09-24 07:48:12 +00:00
& & strinfo - > src_port = = port_src_fwd
2004-12-01 11:54:41 +00:00
& & ADDRESSES_EQUAL ( & ( strinfo - > dest_addr ) , & ( ip_dst_fwd ) )
2003-09-24 07:48:12 +00:00
& & strinfo - > dest_port = = port_dst_fwd )
{
filtered_list = g_list_prepend ( filtered_list , strinfo ) ;
}
2004-12-01 11:54:41 +00:00
if ( ADDRESSES_EQUAL ( & ( strinfo - > src_addr ) , & ( ip_src_rev ) )
2003-09-24 07:48:12 +00:00
& & strinfo - > src_port = = port_src_rev
2004-12-01 11:54:41 +00:00
& & ADDRESSES_EQUAL ( & ( strinfo - > dest_addr ) , & ( ip_dst_rev ) )
2003-09-24 07:48:12 +00:00
& & strinfo - > dest_port = = port_dst_rev )
{
+ + nfound ;
filtered_list = g_list_append ( filtered_list , strinfo ) ;
if ( ssrc_rev = = 0 )
ssrc_rev = strinfo - > ssrc ;
}
strinfo_list = g_list_next ( strinfo_list ) ;
}
/* if more than one reverse streams found, we let the user choose the right one */
if ( nfound > 1 ) {
rtpstream_dlg_show ( filtered_list ) ;
return ;
}
else {
rtp_analysis (
2004-12-01 11:54:41 +00:00
& ip_src_fwd ,
2003-09-24 07:48:12 +00:00
port_src_fwd ,
2004-12-01 11:54:41 +00:00
& ip_dst_fwd ,
2003-09-24 07:48:12 +00:00
port_dst_fwd ,
ssrc_fwd ,
2004-12-01 11:54:41 +00:00
& ip_src_rev ,
2003-09-24 07:48:12 +00:00
port_src_rev ,
2004-12-01 11:54:41 +00:00
& ip_dst_rev ,
2003-09-24 07:48:12 +00:00
port_dst_rev ,
ssrc_rev
) ;
}
}
/****************************************************************************/
static void
2006-02-11 13:05:24 +00:00
rtp_analysis_init ( const char * dummy _U_ , void * userdata _U_ )
2003-09-24 07:48:12 +00:00
{
rtp_analysis_cb ( NULL , NULL ) ;
}
/****************************************************************************/
void
register_tap_listener_rtp_analysis ( void )
{
2006-02-11 13:05:24 +00:00
register_stat_cmd_arg ( " rtp " , rtp_analysis_init , NULL ) ;
2003-09-24 07:48:12 +00:00
2005-08-19 09:29:41 +00:00
register_stat_menu_item ( " RTP/Stream Analysis... " , REGISTER_STAT_GROUP_TELEPHONY ,
2003-12-17 22:13:08 +00:00
rtp_analysis_cb , NULL , NULL , NULL ) ;
2003-09-24 07:48:12 +00:00
}