2010-08-30 16:10:01 +00:00
/*
2004-09-07 07:54:50 +00:00
* Copyright 2004 , Irene Ruengeler < i . ruengeler [ AT ] fh - muenster . de >
*
2004-09-07 20:07:08 +00:00
* $ Id $
2004-09-07 07:54:50 +00:00
*
2006-05-21 05:12:17 +00:00
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
2004-09-07 07:54:50 +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 .
*/
2010-08-30 16:10:01 +00:00
2004-09-07 07:54:50 +00:00
# ifdef HAVE_CONFIG_H
# include <config.h>
# endif
# include <gtk/gtk.h>
2008-04-13 03:32:24 +00:00
2004-09-07 07:54:50 +00:00
# include <epan/epan_dissect.h>
# include "epan/filesystem.h"
2008-03-01 10:23:57 +00:00
# include <epan/strutil.h>
2004-09-07 07:54:50 +00:00
2008-04-13 03:32:24 +00:00
# include "../globals.h"
2012-01-16 01:07:52 +00:00
# include "ui/simple_dialog.h"
2008-04-13 03:32:24 +00:00
# include "../stat_menu.h"
2012-01-15 21:59:11 +00:00
# include "ui/gtk/gui_stat_menu.h"
# include "ui/gtk/dlg_utils.h"
# include "ui/gtk/gui_utils.h"
# include "ui/gtk/main.h"
# include "ui/gtk/sctp_stat.h"
# include "ui/gtk/gtkglobals.h"
2004-09-07 07:54:50 +00:00
2005-03-22 10:25:07 +00:00
static sctp_assoc_info_t static_assoc ;
2004-09-07 07:54:50 +00:00
void
decrease_childcount ( struct sctp_analyse * parent )
{
2005-05-01 13:55:09 +00:00
if ( parent - > num_children > 0 )
2004-09-07 07:54:50 +00:00
parent - > num_children - - ;
}
void
increase_childcount ( struct sctp_analyse * parent )
{
parent - > num_children + + ;
}
void
set_child ( struct sctp_udata * child , struct sctp_analyse * parent )
{
2005-05-01 13:55:09 +00:00
parent - > children = g_list_append ( parent - > children , child ) ;
2004-09-07 07:54:50 +00:00
}
void
remove_child ( struct sctp_udata * child , struct sctp_analyse * parent )
{
2005-05-01 13:55:09 +00:00
parent - > children = g_list_remove ( parent - > children , child ) ;
2004-09-07 07:54:50 +00:00
}
static void
2011-08-04 22:56:36 +00:00
on_destroy ( GObject * object _U_ , gpointer user_data )
2004-09-07 07:54:50 +00:00
{
2005-03-22 10:25:07 +00:00
struct sctp_analyse * u_data ;
guint16 i , j ;
GList * list ;
struct sctp_udata * child_data ;
2004-09-07 07:54:50 +00:00
2005-05-01 13:55:09 +00:00
u_data = ( struct sctp_analyse * ) user_data ;
2004-09-07 07:54:50 +00:00
if ( u_data - > window )
{
gtk_grab_remove ( GTK_WIDGET ( u_data - > window ) ) ;
gtk_widget_destroy ( GTK_WIDGET ( u_data - > window ) ) ;
}
if ( u_data - > num_children > 0 )
{
2005-05-01 13:55:09 +00:00
j = u_data - > num_children ;
2004-09-07 07:54:50 +00:00
for ( i = 0 ; i < j ; i + + )
{
2005-05-01 13:55:09 +00:00
list = g_list_last ( u_data - > children ) ;
child_data = ( struct sctp_udata * ) list - > data ;
2004-09-07 07:54:50 +00:00
gtk_grab_remove ( GTK_WIDGET ( child_data - > io - > window ) ) ;
gtk_widget_destroy ( GTK_WIDGET ( child_data - > io - > window ) ) ;
}
g_list_free ( u_data - > children ) ;
u_data - > children = NULL ;
}
2010-08-30 16:10:01 +00:00
2004-09-07 07:54:50 +00:00
g_free ( u_data - > analyse_nb - > page2 ) ;
g_free ( u_data - > analyse_nb - > page3 ) ;
g_free ( u_data - > analyse_nb ) ;
2005-05-01 13:55:09 +00:00
if ( sctp_stat_get_info ( ) - > children ! = NULL )
2004-09-07 07:54:50 +00:00
{
remove_analyse_child ( u_data ) ;
decrease_analyse_childcount ( ) ;
}
g_free ( u_data ) ;
}
static void
2005-07-28 07:51:52 +00:00
on_notebook_switch_page ( void )
2004-09-07 07:54:50 +00:00
{
}
2005-03-22 10:25:07 +00:00
static void on_chunk_stat_bt ( GtkWidget * widget _U_ , struct sctp_analyse * u_data )
2004-09-07 07:54:50 +00:00
{
2005-05-01 13:55:09 +00:00
sctp_assoc_info_t * assinfo = NULL ;
2005-03-22 10:25:07 +00:00
int i ;
2004-09-07 07:54:50 +00:00
2005-05-01 13:55:09 +00:00
assinfo = & static_assoc ;
assinfo - > addr_chunk_count = ( static_assoc . addr_chunk_count ) ;
2005-03-22 10:25:07 +00:00
for ( i = 0 ; i < NUM_CHUNKS ; i + + )
{
2005-05-01 13:55:09 +00:00
assinfo - > chunk_count [ i ] = static_assoc . chunk_count [ i ] ;
assinfo - > ep1_chunk_count [ i ] = static_assoc . ep1_chunk_count [ i ] ;
assinfo - > ep2_chunk_count [ i ] = static_assoc . ep2_chunk_count [ i ] ;
2005-03-22 10:25:07 +00:00
}
2005-05-01 13:55:09 +00:00
u_data - > assoc = assinfo ;
2005-03-22 10:25:07 +00:00
sctp_chunk_dlg_show ( u_data ) ;
2004-09-07 07:54:50 +00:00
}
static void on_close_dlg ( GtkWidget * widget _U_ , struct sctp_analyse * u_data )
{
if ( u_data - > window )
{
gtk_grab_remove ( GTK_WIDGET ( u_data - > window ) ) ;
gtk_widget_destroy ( GTK_WIDGET ( u_data - > window ) ) ;
}
}
2005-03-22 10:25:07 +00:00
static void on_chunk1_dlg ( GtkWidget * widget _U_ , struct sctp_analyse * u_data )
{
2005-05-01 13:55:09 +00:00
sctp_assoc_info_t * assinfo = NULL ;
2010-08-30 16:10:01 +00:00
2005-05-01 13:55:09 +00:00
assinfo = & static_assoc ;
assinfo - > addr_chunk_count = ( static_assoc . addr_chunk_count ) ;
u_data - > assoc = assinfo ;
2005-03-22 10:25:07 +00:00
sctp_chunk_stat_dlg_show ( 1 , u_data ) ;
}
static void on_chunk2_dlg ( GtkWidget * widget _U_ , struct sctp_analyse * u_data )
{
sctp_assoc_info_t * assinfo = NULL ;
2005-05-01 13:55:09 +00:00
assinfo = & static_assoc ;
2010-08-30 16:10:01 +00:00
assinfo - > addr_chunk_count = ( static_assoc . addr_chunk_count ) ;
2005-05-01 13:55:09 +00:00
u_data - > assoc = assinfo ;
2005-03-22 10:25:07 +00:00
sctp_chunk_stat_dlg_show ( 2 , u_data ) ;
}
2004-09-07 07:54:50 +00:00
static void on_graph1_dlg ( GtkWidget * widget _U_ , struct sctp_analyse * u_data )
{
create_graph ( 1 , u_data ) ;
}
static void on_graph2_dlg ( GtkWidget * widget _U_ , struct sctp_analyse * u_data )
{
create_graph ( 2 , u_data ) ;
}
static void on_graph_byte1_dlg ( GtkWidget * widget _U_ , struct sctp_analyse * u_data )
{
create_byte_graph ( 1 , u_data ) ;
}
static void on_graph_byte2_dlg ( GtkWidget * widget _U_ , struct sctp_analyse * u_data )
{
create_byte_graph ( 2 , u_data ) ;
}
void
update_analyse_dlg ( struct sctp_analyse * u_data )
{
2005-03-22 10:25:07 +00:00
gchar label_txt [ 50 ] ;
gchar field [ 1 ] [ MAX_ADDRESS_LEN ] ;
GList * list ;
2005-05-01 13:55:09 +00:00
address * store = NULL ;
2009-09-01 10:12:27 +00:00
GtkListStore * list_store = NULL ;
GtkTreeIter iter ;
2010-08-30 16:10:01 +00:00
2005-05-01 13:55:09 +00:00
if ( u_data - > assoc = = NULL )
2005-03-22 10:25:07 +00:00
return ;
2004-09-07 07:54:50 +00:00
if ( u_data - > window ! = NULL )
{
2010-08-30 16:10:01 +00:00
gtk_list_store_clear ( GTK_LIST_STORE ( gtk_tree_view_get_model ( GTK_TREE_VIEW
2009-09-01 10:12:27 +00:00
( u_data - > analyse_nb - > page2 - > clist ) ) ) ) ;
gtk_list_store_clear ( GTK_LIST_STORE ( gtk_tree_view_get_model ( GTK_TREE_VIEW
( u_data - > analyse_nb - > page3 - > clist ) ) ) ) ;
2004-09-07 07:54:50 +00:00
}
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Checksum Type: %s " , u_data - > assoc - > checksum_type ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > checktype ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Checksum Errors: %u " , u_data - > assoc - > n_checksum_errors ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > checksum ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Bundling Errors: %u " , u_data - > assoc - > n_bundling_errors ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > bundling ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Padding Errors: %u " , u_data - > assoc - > n_padding_errors ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > padding ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Length Errors: %u " , u_data - > assoc - > n_length_errors ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > length ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Value Errors: %u " , u_data - > assoc - > n_value_errors ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > value ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " No of Data Chunks from EP1 to EP2: %u " , u_data - > assoc - > n_data_chunks_ep1 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > chunks_ep1 ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " No of Data Bytes from EP1 to EP2: %u " , u_data - > assoc - > n_data_bytes_ep1 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > bytes_ep1 ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " No of Data Chunks from EP2 to EP1: %u " , u_data - > assoc - > n_data_chunks_ep2 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > chunks_ep2 ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " No of Data Bytes from EP2 to EP1: %u " , u_data - > assoc - > n_data_bytes_ep2 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > bytes_ep2 ) , label_txt ) ;
2005-05-01 13:55:09 +00:00
if ( u_data - > assoc - > init = = TRUE )
2005-03-22 10:25:07 +00:00
gtk_frame_set_label ( GTK_FRAME ( u_data - > analyse_nb - > page2 - > addr_frame ) , " Complete list of IP-Addresses as provided in the INIT-Chunk " ) ;
2005-05-01 13:55:09 +00:00
else if ( u_data - > assoc - > initack = = TRUE & & u_data - > assoc - > initack_dir = = 1 )
2004-09-07 07:54:50 +00:00
gtk_frame_set_label ( GTK_FRAME ( u_data - > analyse_nb - > page2 - > addr_frame ) , " Complete list of IP-Addresses as provided in the INITACK-Chunk " ) ;
else
gtk_frame_set_label ( GTK_FRAME ( u_data - > analyse_nb - > page2 - > addr_frame ) , " List of used IP-Addresses " ) ;
2005-05-01 13:55:09 +00:00
if ( u_data - > assoc - > addr1 ! = NULL )
2005-03-22 10:25:07 +00:00
{
list = g_list_first ( u_data - > assoc - > addr1 ) ;
while ( list )
2004-09-07 07:54:50 +00:00
{
2005-03-22 10:25:07 +00:00
store = ( address * ) ( list - > data ) ;
2005-05-01 13:55:09 +00:00
if ( store - > type = = AT_IPv4 )
2004-09-07 07:54:50 +00:00
{
2005-03-22 10:25:07 +00:00
g_snprintf ( field [ 0 ] , 30 , " %s " , ip_to_str ( ( const guint8 * ) ( store - > data ) ) ) ;
2004-09-07 07:54:50 +00:00
}
2005-05-01 13:55:09 +00:00
else if ( store - > type = = AT_IPv6 )
2010-08-30 16:10:01 +00:00
{
2005-03-22 10:25:07 +00:00
g_snprintf ( field [ 0 ] , 40 , " %s " , ip6_to_str ( ( const struct e_in6_addr * ) ( store - > data ) ) ) ;
}
2009-09-01 10:12:27 +00:00
list_store = GTK_LIST_STORE ( gtk_tree_view_get_model ( GTK_TREE_VIEW ( u_data - > analyse_nb - > page2 - > clist ) ) ) ; /* Get store */
2011-06-07 22:50:49 +00:00
gtk_list_store_insert_with_values ( list_store , & iter , G_MAXINT ,
0 , field [ 0 ] , - 1 ) ;
2005-03-22 10:25:07 +00:00
list = g_list_next ( list ) ;
2004-09-07 07:54:50 +00:00
}
2005-03-22 10:25:07 +00:00
}
else
{
2004-09-07 07:54:50 +00:00
return ;
2005-03-22 10:25:07 +00:00
}
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Port: %u " , u_data - > assoc - > port1 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > port ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Sent Verification Tag: 0x%x " , u_data - > assoc - > verification_tag1 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > veritag ) , label_txt ) ;
2005-05-01 13:55:09 +00:00
if ( u_data - > assoc - > init = = TRUE | | ( u_data - > assoc - > initack = = TRUE & & u_data - > assoc - > initack_dir = = 1 ) )
2004-09-07 07:54:50 +00:00
{
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Requested Number of Inbound Streams: %u " , u_data - > assoc - > instream1 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > max_in ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Minimum Number of Inbound Streams: %u " , ( ( u_data - > assoc - > instream1 > u_data - > assoc - > outstream2 ) ? u_data - > assoc - > outstream2 : u_data - > assoc - > instream1 ) ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > min_in ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Provided Number of Outbound Streams: %u " , u_data - > assoc - > outstream1 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > max_out ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Minimum Number of Outbound Streams: %u " , ( ( u_data - > assoc - > outstream1 > u_data - > assoc - > instream2 ) ? u_data - > assoc - > instream2 : u_data - > assoc - > outstream1 ) ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > max_out ) , label_txt ) ;
}
else
{
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Used Number of Inbound Streams: %u " , u_data - > assoc - > instream1 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > max_in ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Used Number of Outbound Streams: %u " , u_data - > assoc - > outstream1 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > max_out ) , label_txt ) ;
}
2005-05-01 13:55:09 +00:00
if ( u_data - > assoc - > initack = = TRUE & & u_data - > assoc - > initack_dir = = 2 )
2005-03-22 10:25:07 +00:00
gtk_frame_set_label ( GTK_FRAME ( u_data - > analyse_nb - > page3 - > addr_frame ) , " Complete list of IP-Addresses as provided in the INITACK-Chunk " ) ;
2004-09-07 07:54:50 +00:00
else
gtk_frame_set_label ( GTK_FRAME ( u_data - > analyse_nb - > page3 - > addr_frame ) , " List of used IP-Addresses " ) ;
2005-05-01 13:55:09 +00:00
if ( u_data - > assoc - > addr2 ! = NULL )
2004-09-07 07:54:50 +00:00
{
2005-03-22 10:25:07 +00:00
list = g_list_first ( u_data - > assoc - > addr2 ) ;
2004-09-07 07:54:50 +00:00
while ( list )
{
2005-02-04 22:45:15 +00:00
store = ( address * ) ( list - > data ) ;
2005-05-01 13:55:09 +00:00
if ( store - > type = = AT_IPv4 )
2004-09-07 07:54:50 +00:00
{
2005-03-22 10:25:07 +00:00
g_snprintf ( field [ 0 ] , 30 , " %s " , ip_to_str ( ( const guint8 * ) ( store - > data ) ) ) ;
2004-09-07 07:54:50 +00:00
}
2005-05-01 13:55:09 +00:00
else if ( store - > type = = AT_IPv6 )
2004-09-07 07:54:50 +00:00
{
2005-03-22 10:25:07 +00:00
g_snprintf ( field [ 0 ] , 40 , " %s " , ip6_to_str ( ( const struct e_in6_addr * ) ( store - > data ) ) ) ;
2004-09-07 07:54:50 +00:00
}
2009-09-01 10:12:27 +00:00
list_store = GTK_LIST_STORE ( gtk_tree_view_get_model ( GTK_TREE_VIEW ( u_data - > analyse_nb - > page3 - > clist ) ) ) ; /* Get store */
2011-06-07 22:50:49 +00:00
gtk_list_store_insert_with_values ( list_store , & iter , G_MAXINT ,
0 , field [ 0 ] , - 1 ) ;
2004-09-07 07:54:50 +00:00
list = g_list_next ( list ) ;
}
}
else
2005-03-22 10:25:07 +00:00
{
2004-09-07 07:54:50 +00:00
return ;
2005-03-22 10:25:07 +00:00
}
2004-09-07 07:54:50 +00:00
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Port: %u " , u_data - > assoc - > port2 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > port ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Sent Verification Tag: 0x%x " , u_data - > assoc - > verification_tag2 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > veritag ) , label_txt ) ;
2005-05-01 13:55:09 +00:00
if ( u_data - > assoc - > initack = = TRUE )
2004-09-07 07:54:50 +00:00
{
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Requested Number of Inbound Streams: %u " , u_data - > assoc - > instream2 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > max_in ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Minimum Number of Inbound Streams: %u " , ( ( u_data - > assoc - > instream2 > u_data - > assoc - > outstream1 ) ? u_data - > assoc - > outstream1 : u_data - > assoc - > instream2 ) ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > min_in ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Provided Number of Outbound Streams: %u " , u_data - > assoc - > outstream2 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > max_out ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Minimum Number of Outbound Streams: %u " , ( ( u_data - > assoc - > outstream2 > u_data - > assoc - > instream1 ) ? u_data - > assoc - > instream1 : u_data - > assoc - > outstream2 ) ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > min_out ) , label_txt ) ;
}
else
{
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Used Number of Inbound Streams: %u " , u_data - > assoc - > instream2 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > max_in ) , label_txt ) ;
2009-03-19 17:49:11 +00:00
g_snprintf ( label_txt , sizeof ( label_txt ) , " Used Number of Outbound Streams: %u " , u_data - > assoc - > outstream2 ) ;
2004-09-07 07:54:50 +00:00
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > min_out ) , label_txt ) ;
}
}
2006-06-26 13:18:37 +00:00
2009-09-29 13:04:47 +00:00
static void
2006-06-26 13:18:37 +00:00
sctp_set_filter ( GtkButton * button _U_ , struct sctp_analyse * u_data )
{
gchar * f_string = NULL ;
2007-05-22 21:16:30 +00:00
GList * srclist , * dstlist ;
2006-06-26 13:18:37 +00:00
gchar * str = NULL ;
GString * gstring = NULL ;
struct sockaddr_in * infosrc = NULL ;
struct sockaddr_in * infodst = NULL ;
sctp_assoc_info_t * selected_stream ;
gchar * filter_string = NULL ;
selected_stream = u_data - > assoc ;
2010-08-30 16:10:01 +00:00
2007-05-22 21:16:30 +00:00
if ( selected_stream - > check_address = = FALSE )
{
f_string = g_strdup_printf ( " ((sctp.srcport==%u && sctp.dstport==%u && ((sctp.verification_tag==0x%x && sctp.verification_tag!=0x0) || "
" (sctp.verification_tag==0x0 && sctp.initiate_tag==0x%x) || "
" (sctp.verification_tag==0x%x && (sctp.abort_t_bit==1 || sctp.shutdown_complete_t_bit==1)))) || "
" (sctp.srcport==%u && sctp.dstport==%u && ((sctp.verification_tag==0x%x && sctp.verification_tag!=0x0) || "
" (sctp.verification_tag==0x0 && sctp.initiate_tag==0x%x) || "
" (sctp.verification_tag==0x%x && (sctp.abort_t_bit==1 || sctp.shutdown_complete_t_bit==1))))) " ,
selected_stream - > port1 ,
selected_stream - > port2 ,
selected_stream - > verification_tag1 ,
selected_stream - > initiate_tag ,
selected_stream - > verification_tag2 ,
selected_stream - > port2 ,
selected_stream - > port1 ,
selected_stream - > verification_tag2 ,
selected_stream - > initiate_tag ,
selected_stream - > verification_tag1 ) ;
filter_string = f_string ;
}
else
{
srclist = g_list_first ( selected_stream - > addr1 ) ;
infosrc = ( struct sockaddr_in * ) ( srclist - > data ) ;
gstring = g_string_new ( g_strdup_printf ( " ((sctp.srcport==%u && sctp.dstport==%u && (ip.src==%s " ,
selected_stream - > port1 , selected_stream - > port2 , ip_to_str ( ( const guint8 * ) & ( infosrc - > sin_addr . s_addr ) ) ) ) ;
srclist = g_list_next ( srclist ) ;
2006-06-26 13:18:37 +00:00
2007-05-22 21:16:30 +00:00
while ( srclist )
2006-06-26 13:18:37 +00:00
{
infosrc = ( struct sockaddr_in * ) ( srclist - > data ) ;
2007-05-22 21:16:30 +00:00
str = g_strdup_printf ( " || ip.src==%s " , ip_to_str ( ( const guint8 * ) & ( infosrc - > sin_addr . s_addr ) ) ) ;
g_string_append ( gstring , str ) ;
2006-06-26 13:18:37 +00:00
srclist = g_list_next ( srclist ) ;
2007-05-22 21:16:30 +00:00
}
2006-06-26 13:18:37 +00:00
2007-05-22 21:16:30 +00:00
dstlist = g_list_first ( selected_stream - > addr2 ) ;
infodst = ( struct sockaddr_in * ) ( dstlist - > data ) ;
str = g_strdup_printf ( " ) && (ip.dst==%s " , ip_to_str ( ( const guint8 * ) & ( infodst - > sin_addr . s_addr ) ) ) ;
g_string_append ( gstring , str ) ;
dstlist = g_list_next ( dstlist ) ;
while ( dstlist )
{
2006-06-26 13:18:37 +00:00
infodst = ( struct sockaddr_in * ) ( dstlist - > data ) ;
2007-05-22 21:16:30 +00:00
str = g_strdup_printf ( " || ip.dst==%s " , ip_to_str ( ( const guint8 * ) & ( infodst - > sin_addr . s_addr ) ) ) ;
2006-06-26 13:18:37 +00:00
g_string_append ( gstring , str ) ;
dstlist = g_list_next ( dstlist ) ;
2007-05-22 21:16:30 +00:00
}
srclist = g_list_first ( selected_stream - > addr1 ) ;
infosrc = ( struct sockaddr_in * ) ( srclist - > data ) ;
str = g_strdup_printf ( " )) || (sctp.dstport==%u && sctp.srcport==%u && (ip.dst==%s " ,
selected_stream - > port1 , selected_stream - > port2 , ip_to_str ( ( const guint8 * ) & ( infosrc - > sin_addr . s_addr ) ) ) ;
g_string_append ( gstring , str ) ;
srclist = g_list_next ( srclist ) ;
2006-06-26 13:18:37 +00:00
2007-05-22 21:16:30 +00:00
while ( srclist )
{
2006-06-26 13:18:37 +00:00
infosrc = ( struct sockaddr_in * ) ( srclist - > data ) ;
2007-05-22 21:16:30 +00:00
str = g_strdup_printf ( " || ip.dst==%s " , ip_to_str ( ( const guint8 * ) & ( infosrc - > sin_addr . s_addr ) ) ) ;
2006-06-26 13:18:37 +00:00
g_string_append ( gstring , str ) ;
srclist = g_list_next ( srclist ) ;
2007-05-22 21:16:30 +00:00
}
2006-06-26 13:18:37 +00:00
2007-05-22 21:16:30 +00:00
dstlist = g_list_first ( selected_stream - > addr2 ) ;
infodst = ( struct sockaddr_in * ) ( dstlist - > data ) ;
str = g_strdup_printf ( " ) && (ip.src==%s " , ip_to_str ( ( const guint8 * ) & ( infodst - > sin_addr . s_addr ) ) ) ;
g_string_append ( gstring , str ) ;
dstlist = g_list_next ( dstlist ) ;
while ( dstlist )
{
2006-06-26 13:18:37 +00:00
infodst = ( struct sockaddr_in * ) ( dstlist - > data ) ;
2007-05-22 21:16:30 +00:00
str = g_strdup_printf ( " || ip.src==%s " , ip_to_str ( ( const guint8 * ) & ( infodst - > sin_addr . s_addr ) ) ) ;
2006-06-26 13:18:37 +00:00
g_string_append ( gstring , str ) ;
dstlist = g_list_next ( dstlist ) ;
}
2007-05-22 21:16:30 +00:00
str = g_strdup_printf ( " ))) " ) ;
g_string_append ( gstring , str ) ;
2006-06-26 13:18:37 +00:00
filter_string = gstring - > str ;
g_string_free ( gstring , FALSE ) ;
}
2010-08-30 16:10:01 +00:00
2006-06-26 13:18:37 +00:00
if ( filter_string ! = NULL ) {
gtk_entry_set_text ( GTK_ENTRY ( main_display_filter_widget ) , filter_string ) ;
} else {
g_assert_not_reached ( ) ;
}
}
2004-09-07 07:54:50 +00:00
static void analyse_window_set_title ( struct sctp_analyse * u_data )
{
2005-03-22 10:25:07 +00:00
char * title ;
2010-08-30 16:10:01 +00:00
2004-09-07 07:54:50 +00:00
if ( ! u_data - > window ) {
return ;
}
2005-05-01 13:55:09 +00:00
title = g_strdup_printf ( " SCTP Analyse Association: %s Port1 %u Port2 %u " , cf_get_display_name ( & cfile ) , u_data - > assoc - > port1 , u_data - > assoc - > port2 ) ;
2004-09-07 07:54:50 +00:00
gtk_window_set_title ( GTK_WINDOW ( u_data - > window ) , title ) ;
g_free ( title ) ;
}
2009-09-01 10:12:27 +00:00
static
2009-09-29 13:04:47 +00:00
GtkWidget * create_list ( void )
2009-09-01 10:12:27 +00:00
{
GtkListStore * list_store ;
GtkWidget * list ;
GtkTreeViewColumn * column ;
GtkCellRenderer * renderer ;
GtkTreeView * list_view ;
list_store = gtk_list_store_new ( 1 ,
2011-06-07 22:50:49 +00:00
G_TYPE_STRING /* IP address */
) ;
2010-08-30 16:10:01 +00:00
2011-06-07 22:50:49 +00:00
/* Create a view */
list = gtk_tree_view_new_with_model ( GTK_TREE_MODEL ( list_store ) ) ;
2009-09-01 10:12:27 +00:00
list_view = GTK_TREE_VIEW ( list ) ;
/* Speed up the list display */
gtk_tree_view_set_fixed_height_mode ( list_view , TRUE ) ;
2011-06-07 22:50:49 +00:00
/* The view now holds a reference. We can get rid of our own reference */
g_object_unref ( G_OBJECT ( list_store ) ) ;
2009-09-01 10:12:27 +00:00
2011-06-07 22:50:49 +00:00
/*
* 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 ( " Address " , renderer ,
" text " , 0 ,
NULL ) ;
2009-09-01 10:12:27 +00:00
2011-06-07 22:50:49 +00:00
gtk_tree_view_column_set_resizable ( column , TRUE ) ;
gtk_tree_view_column_set_sizing ( column , GTK_TREE_VIEW_COLUMN_FIXED ) ;
gtk_tree_view_column_set_min_width ( column , 300 ) ;
2009-09-01 10:12:27 +00:00
/* Add the column to the view. */
2011-06-07 22:50:49 +00:00
gtk_tree_view_append_column ( list_view , column ) ;
2010-08-30 16:10:01 +00:00
2009-09-01 10:12:27 +00:00
gtk_tree_view_set_headers_visible ( list_view , FALSE ) ;
return list ;
}
2005-08-20 14:02:00 +00:00
static void create_analyse_window ( struct sctp_analyse * u_data )
2004-09-07 07:54:50 +00:00
{
GtkWidget * window = NULL ;
GtkWidget * notebook ;
GtkWidget * main_vb , * page1 , * page2 , * page3 , * hbox , * vbox_l , * vbox_r , * addr_hb , * stat_fr ;
GtkWidget * hbox_l1 , * hbox_l2 , * label , * h_button_box ;
2006-06-26 13:18:37 +00:00
GtkWidget * chunk_stat_bt , * close_bt , * graph_bt1 , * graph_bt2 , * chunk_bt1 , * bt_filter ;
2004-09-07 07:54:50 +00:00
u_data - > analyse_nb = g_malloc ( sizeof ( struct notes ) ) ;
window = gtk_window_new ( GTK_WINDOW_TOPLEVEL ) ;
gtk_window_set_position ( GTK_WINDOW ( window ) , GTK_WIN_POS_CENTER ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( window , " destroy " , G_CALLBACK ( on_destroy ) , u_data ) ;
2004-09-07 07:54:50 +00:00
/* Container for each row of widgets */
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 ) ;
2004-09-07 07:54:50 +00:00
gtk_container_add ( GTK_CONTAINER ( window ) , main_vb ) ;
gtk_widget_show ( main_vb ) ;
/* 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:55:44 +00:00
g_object_set_data ( G_OBJECT ( window ) , " notebook " , notebook ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( notebook , " switch_page " , G_CALLBACK ( on_notebook_switch_page ) , NULL ) ;
2004-09-07 07:54:50 +00:00
page1 = gtk_vbox_new ( FALSE , 8 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( page1 ) , 8 ) ;
u_data - > analyse_nb - > checktype = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > checktype , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > checktype ) , 0 , 0 ) ;
u_data - > analyse_nb - > checksum = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > checksum , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > checksum ) , 0 , 0 ) ;
u_data - > analyse_nb - > bundling = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > bundling , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > bundling ) , 0 , 0 ) ;
u_data - > analyse_nb - > padding = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > padding , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > padding ) , 0 , 0 ) ;
u_data - > analyse_nb - > length = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > length , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > length ) , 0 , 0 ) ;
u_data - > analyse_nb - > value = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > value , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > value ) , 0 , 0 ) ;
u_data - > analyse_nb - > chunks_ep1 = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > chunks_ep1 , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > chunks_ep1 ) , 0 , 0 ) ;
u_data - > analyse_nb - > bytes_ep1 = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > bytes_ep1 , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > bytes_ep1 ) , 0 , 0 ) ;
u_data - > analyse_nb - > chunks_ep2 = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > chunks_ep2 , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > chunks_ep2 ) , 0 , 0 ) ;
u_data - > analyse_nb - > bytes_ep2 = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , u_data - > analyse_nb - > bytes_ep2 , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > bytes_ep2 ) , 0 , 0 ) ;
hbox = gtk_hbutton_box_new ( ) ;
gtk_box_pack_start ( GTK_BOX ( page1 ) , hbox , FALSE , FALSE , 0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( hbox ) , 10 ) ;
gtk_button_box_set_layout ( GTK_BUTTON_BOX ( hbox ) , GTK_BUTTONBOX_SPREAD ) ;
2008-07-08 02:43:40 +00:00
gtk_box_set_spacing ( GTK_BOX ( hbox ) , 0 ) ;
2004-09-07 07:54:50 +00:00
gtk_widget_show ( hbox ) ;
2005-03-22 10:25:07 +00:00
chunk_stat_bt = gtk_button_new_with_label ( " Chunk Statistics " ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , chunk_stat_bt , FALSE , FALSE , 0 ) ;
gtk_widget_show ( chunk_stat_bt ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( chunk_stat_bt , " clicked " , G_CALLBACK ( on_chunk_stat_bt ) , u_data ) ;
2004-09-07 07:54:50 +00:00
2006-06-26 13:18:37 +00:00
bt_filter = gtk_button_new_with_label ( " Set filter " ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , bt_filter , FALSE , FALSE , 0 ) ;
gtk_widget_show ( bt_filter ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( bt_filter , " clicked " , G_CALLBACK ( sctp_set_filter ) , u_data ) ;
2004-09-07 07:54:50 +00:00
2008-04-11 18:58:19 +00:00
close_bt = gtk_button_new_from_stock ( GTK_STOCK_CLOSE ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( hbox ) , close_bt , FALSE , FALSE , 0 ) ;
gtk_widget_show ( close_bt ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( close_bt , " clicked " , G_CALLBACK ( on_close_dlg ) , u_data ) ;
2004-09-07 07:54:50 +00:00
/* tab */
label = gtk_label_new ( " Statistics " ) ;
gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ) , page1 , label ) ;
/* page for endpoint 1 */
page2 = gtk_vbox_new ( FALSE , 8 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( page2 ) , 8 ) ;
u_data - > analyse_nb - > page2 = g_malloc ( sizeof ( struct page ) ) ;
2005-03-22 10:25:07 +00:00
u_data - > analyse_nb - > page2 - > addr_frame = gtk_frame_new ( NULL ) ;
2004-09-07 07:54:50 +00:00
gtk_container_add ( GTK_CONTAINER ( page2 ) , u_data - > analyse_nb - > page2 - > addr_frame ) ;
addr_hb = gtk_hbox_new ( FALSE , 3 ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( addr_hb ) , 5 ) ;
2004-09-07 07:54:50 +00:00
gtk_container_add ( GTK_CONTAINER ( u_data - > analyse_nb - > page2 - > addr_frame ) , addr_hb ) ;
u_data - > analyse_nb - > page2 - > scrolled_window = scrolled_window_new ( NULL , NULL ) ;
2008-04-11 20:31:05 +00:00
gtk_widget_set_size_request ( u_data - > analyse_nb - > page2 - > scrolled_window , 560 , 100 ) ;
2004-09-07 07:54:50 +00:00
2009-09-01 10:12:27 +00:00
u_data - > analyse_nb - > page2 - > clist = create_list ( ) ;
2004-09-07 07:54:50 +00:00
gtk_widget_show ( u_data - > analyse_nb - > page2 - > clist ) ;
2005-05-01 13:55:09 +00:00
gtk_container_add ( GTK_CONTAINER ( u_data - > analyse_nb - > page2 - > scrolled_window ) , u_data - > analyse_nb - > page2 - > clist ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( addr_hb ) , u_data - > analyse_nb - > page2 - > scrolled_window , TRUE , TRUE , 0 ) ;
gtk_widget_show ( u_data - > analyse_nb - > page2 - > scrolled_window ) ;
stat_fr = gtk_frame_new ( NULL ) ;
2005-03-22 10:25:07 +00:00
gtk_container_add ( GTK_CONTAINER ( page2 ) , stat_fr ) ;
2004-09-07 07:54:50 +00:00
hbox = gtk_hbox_new ( FALSE , 3 ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( hbox ) , 5 ) ;
2004-09-07 07:54:50 +00:00
gtk_container_add ( GTK_CONTAINER ( stat_fr ) , hbox ) ;
2005-05-01 13:55:09 +00:00
vbox_l = gtk_vbox_new ( FALSE , 3 ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( hbox ) , vbox_l , TRUE , TRUE , 0 ) ;
2005-03-22 10:25:07 +00:00
2005-05-01 13:55:09 +00:00
hbox_l1 = gtk_hbox_new ( FALSE , 3 ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( vbox_l ) , hbox_l1 , TRUE , TRUE , 0 ) ;
u_data - > analyse_nb - > page2 - > port = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( hbox_l1 ) , u_data - > analyse_nb - > page2 - > port , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page2 - > port ) , 0 , 0 ) ;
2005-05-01 13:55:09 +00:00
hbox_l2 = gtk_hbox_new ( FALSE , 3 ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( vbox_l ) , hbox_l2 , TRUE , TRUE , 0 ) ;
u_data - > analyse_nb - > page2 - > veritag = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( hbox_l2 ) , u_data - > analyse_nb - > page2 - > veritag , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page2 - > veritag ) , 0 , 0 ) ;
gtk_widget_show ( vbox_l ) ;
2005-05-01 13:55:09 +00:00
vbox_r = gtk_vbox_new ( FALSE , 3 ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( hbox ) , vbox_r , TRUE , TRUE , 0 ) ;
u_data - > analyse_nb - > page2 - > max_in = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( vbox_r ) , u_data - > analyse_nb - > page2 - > max_in , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page2 - > max_in ) , 0 , 0 ) ;
u_data - > analyse_nb - > page2 - > min_in = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( vbox_r ) , u_data - > analyse_nb - > page2 - > min_in , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page2 - > min_in ) , 0 , 0 ) ;
u_data - > analyse_nb - > page2 - > max_out = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( vbox_r ) , u_data - > analyse_nb - > page2 - > max_out , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page2 - > max_out ) , 0 , 0 ) ;
u_data - > analyse_nb - > page2 - > min_out = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( vbox_r ) , u_data - > analyse_nb - > page2 - > min_out , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page2 - > min_out ) , 0 , 0 ) ;
gtk_widget_show ( vbox_r ) ;
h_button_box = gtk_hbutton_box_new ( ) ;
gtk_box_pack_start ( GTK_BOX ( page2 ) , h_button_box , FALSE , FALSE , 0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( h_button_box ) , 10 ) ;
gtk_button_box_set_layout ( GTK_BUTTON_BOX ( h_button_box ) , GTK_BUTTONBOX_SPREAD ) ;
2008-07-08 02:43:40 +00:00
gtk_box_set_spacing ( GTK_BOX ( h_button_box ) , 0 ) ;
2004-09-07 07:54:50 +00:00
gtk_widget_show ( h_button_box ) ;
2010-08-30 16:10:01 +00:00
2005-03-22 10:25:07 +00:00
chunk_bt1 = gtk_button_new_with_label ( " Chunk Statistics " ) ;
gtk_box_pack_start ( GTK_BOX ( h_button_box ) , chunk_bt1 , FALSE , FALSE , 0 ) ;
gtk_widget_show ( chunk_bt1 ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( chunk_bt1 , " clicked " , G_CALLBACK ( on_chunk1_dlg ) , u_data ) ;
2004-09-07 07:54:50 +00:00
graph_bt1 = gtk_button_new_with_label ( " Graph TSN " ) ;
gtk_box_pack_start ( GTK_BOX ( h_button_box ) , graph_bt1 , FALSE , FALSE , 0 ) ;
gtk_widget_show ( graph_bt1 ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( graph_bt1 , " clicked " , G_CALLBACK ( on_graph1_dlg ) , u_data ) ;
2004-09-07 07:54:50 +00:00
graph_bt2 = gtk_button_new_with_label ( " Graph Bytes " ) ;
gtk_box_pack_start ( GTK_BOX ( h_button_box ) , graph_bt2 , FALSE , FALSE , 0 ) ;
gtk_widget_show ( graph_bt2 ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( graph_bt2 , " clicked " , G_CALLBACK ( on_graph_byte1_dlg ) , u_data ) ;
2006-04-04 09:04:08 +00:00
if ( u_data - > assoc - > n_array_tsn1 = = 0 )
{
gtk_widget_set_sensitive ( graph_bt1 , FALSE ) ;
gtk_widget_set_sensitive ( graph_bt2 , FALSE ) ;
}
2008-04-11 18:58:19 +00:00
close_bt = gtk_button_new_from_stock ( GTK_STOCK_CLOSE ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( h_button_box ) , close_bt , FALSE , FALSE , 0 ) ;
gtk_widget_show ( close_bt ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( close_bt , " clicked " , G_CALLBACK ( on_close_dlg ) , u_data ) ;
2004-09-07 07:54:50 +00:00
label = gtk_label_new ( " Endpoint 1 " ) ;
gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ) , page2 , label ) ;
2005-03-22 10:25:07 +00:00
/* same page for endpoint 2*/
2004-09-07 07:54:50 +00:00
page3 = gtk_vbox_new ( FALSE , 8 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( page3 ) , 8 ) ;
u_data - > analyse_nb - > page3 = g_malloc ( sizeof ( struct page ) ) ;
u_data - > analyse_nb - > page3 - > addr_frame = gtk_frame_new ( NULL ) ;
gtk_container_add ( GTK_CONTAINER ( page3 ) , u_data - > analyse_nb - > page3 - > addr_frame ) ;
addr_hb = gtk_hbox_new ( FALSE , 3 ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( addr_hb ) , 5 ) ;
2004-09-07 07:54:50 +00:00
gtk_container_add ( GTK_CONTAINER ( u_data - > analyse_nb - > page3 - > addr_frame ) , addr_hb ) ;
u_data - > analyse_nb - > page3 - > scrolled_window = scrolled_window_new ( NULL , NULL ) ;
2008-04-11 20:31:05 +00:00
gtk_widget_set_size_request ( u_data - > analyse_nb - > page3 - > scrolled_window , 560 , 100 ) ;
2005-03-22 10:25:07 +00:00
2009-09-01 10:12:27 +00:00
u_data - > analyse_nb - > page3 - > clist = create_list ( ) ;
2010-08-30 16:10:01 +00:00
gtk_widget_show ( u_data - > analyse_nb - > page3 - > clist ) ;
2004-09-07 07:54:50 +00:00
gtk_container_add ( GTK_CONTAINER ( u_data - > analyse_nb - > page3 - > scrolled_window ) ,
u_data - > analyse_nb - > page3 - > clist ) ;
gtk_box_pack_start ( GTK_BOX ( addr_hb ) , u_data - > analyse_nb - > page3 - > scrolled_window , TRUE , TRUE , 0 ) ;
gtk_widget_show ( u_data - > analyse_nb - > page3 - > scrolled_window ) ;
stat_fr = gtk_frame_new ( NULL ) ;
2005-03-22 10:25:07 +00:00
gtk_container_add ( GTK_CONTAINER ( page3 ) , stat_fr ) ;
2004-09-07 07:54:50 +00:00
hbox = gtk_hbox_new ( FALSE , 3 ) ;
2008-06-29 15:51:43 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( hbox ) , 5 ) ;
2004-09-07 07:54:50 +00:00
gtk_container_add ( GTK_CONTAINER ( stat_fr ) , hbox ) ;
2005-05-01 13:55:09 +00:00
vbox_l = gtk_vbox_new ( FALSE , 3 ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( hbox ) , vbox_l , TRUE , TRUE , 0 ) ;
2010-08-30 16:10:01 +00:00
2005-05-01 13:55:09 +00:00
hbox_l1 = gtk_hbox_new ( FALSE , 3 ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( vbox_l ) , hbox_l1 , TRUE , TRUE , 0 ) ;
u_data - > analyse_nb - > page3 - > port = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( hbox_l1 ) , u_data - > analyse_nb - > page3 - > port , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page3 - > port ) , 0 , 0 ) ;
2005-05-01 13:55:09 +00:00
hbox_l2 = gtk_hbox_new ( FALSE , 3 ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( vbox_l ) , hbox_l2 , TRUE , TRUE , 0 ) ;
u_data - > analyse_nb - > page3 - > veritag = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( hbox_l2 ) , u_data - > analyse_nb - > page3 - > veritag , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page3 - > veritag ) , 0 , 0 ) ;
gtk_widget_show ( vbox_l ) ;
vbox_r = gtk_vbox_new ( FALSE , 3 ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , vbox_r , TRUE , TRUE , 0 ) ;
u_data - > analyse_nb - > page3 - > max_in = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( vbox_r ) , u_data - > analyse_nb - > page3 - > max_in , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page3 - > max_in ) , 0 , 0 ) ;
u_data - > analyse_nb - > page3 - > min_in = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( vbox_r ) , u_data - > analyse_nb - > page3 - > min_in , TRUE , TRUE , 0 ) ;
2010-08-30 16:10:01 +00:00
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page3 - > min_in ) , 0 , 0 ) ;
2004-09-07 07:54:50 +00:00
u_data - > analyse_nb - > page3 - > max_out = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( vbox_r ) , u_data - > analyse_nb - > page3 - > max_out , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page3 - > max_out ) , 0 , 0 ) ;
u_data - > analyse_nb - > page3 - > min_out = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( vbox_r ) , u_data - > analyse_nb - > page3 - > min_out , TRUE , TRUE , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( u_data - > analyse_nb - > page3 - > min_out ) , 0 , 0 ) ;
gtk_widget_show ( vbox_r ) ;
h_button_box = gtk_hbutton_box_new ( ) ;
gtk_box_pack_start ( GTK_BOX ( page3 ) , h_button_box , FALSE , FALSE , 0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( h_button_box ) , 10 ) ;
gtk_button_box_set_layout ( GTK_BUTTON_BOX ( h_button_box ) , GTK_BUTTONBOX_SPREAD ) ;
2008-07-08 02:43:40 +00:00
gtk_box_set_spacing ( GTK_BOX ( h_button_box ) , 0 ) ;
2004-09-07 07:54:50 +00:00
gtk_widget_show ( h_button_box ) ;
2010-08-30 16:10:01 +00:00
2005-03-22 10:25:07 +00:00
chunk_bt1 = gtk_button_new_with_label ( " Chunk Statistics " ) ;
gtk_box_pack_start ( GTK_BOX ( h_button_box ) , chunk_bt1 , FALSE , FALSE , 0 ) ;
gtk_widget_show ( chunk_bt1 ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( chunk_bt1 , " clicked " , G_CALLBACK ( on_chunk2_dlg ) , u_data ) ;
2010-08-30 16:10:01 +00:00
2005-07-12 21:04:05 +00:00
graph_bt1 = gtk_button_new_with_label ( " Graph TSN " ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( h_button_box ) , graph_bt1 , FALSE , FALSE , 0 ) ;
gtk_widget_show ( graph_bt1 ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( graph_bt1 , " clicked " , G_CALLBACK ( on_graph2_dlg ) , u_data ) ;
2004-09-07 07:54:50 +00:00
graph_bt2 = gtk_button_new_with_label ( " Graph Bytes " ) ;
gtk_box_pack_start ( GTK_BOX ( h_button_box ) , graph_bt2 , FALSE , FALSE , 0 ) ;
gtk_widget_show ( graph_bt2 ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( graph_bt2 , " clicked " , G_CALLBACK ( on_graph_byte2_dlg ) , u_data ) ;
2006-04-04 09:04:08 +00:00
if ( u_data - > assoc - > n_array_tsn2 = = 0 )
{
gtk_widget_set_sensitive ( graph_bt1 , FALSE ) ;
gtk_widget_set_sensitive ( graph_bt2 , FALSE ) ;
}
2008-04-11 18:58:19 +00:00
close_bt = gtk_button_new_from_stock ( GTK_STOCK_CLOSE ) ;
2004-09-07 07:54:50 +00:00
gtk_box_pack_start ( GTK_BOX ( h_button_box ) , close_bt , FALSE , FALSE , 0 ) ;
gtk_widget_show ( close_bt ) ;
2008-04-11 23:16:06 +00:00
g_signal_connect ( close_bt , " clicked " , G_CALLBACK ( on_close_dlg ) , u_data ) ;
2004-09-07 07:54:50 +00:00
label = gtk_label_new ( " Endpoint 2 " ) ;
gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ) , page3 , label ) ;
/* show all notebooks */
gtk_widget_show_all ( notebook ) ;
gtk_widget_show ( window ) ;
2005-05-01 13:55:09 +00:00
u_data - > window = window ;
2004-09-07 07:54:50 +00:00
analyse_window_set_title ( u_data ) ;
update_analyse_dlg ( u_data ) ;
}
void assoc_analyse ( sctp_assoc_info_t * assoc )
{
2005-03-22 10:25:07 +00:00
struct sctp_analyse * u_data ;
int i ;
2004-09-07 07:54:50 +00:00
u_data = g_malloc ( sizeof ( struct sctp_analyse ) ) ;
2005-05-01 13:55:09 +00:00
u_data - > assoc = assoc ;
u_data - > assoc - > addr_chunk_count = assoc - > addr_chunk_count ;
u_data - > window = NULL ;
u_data - > analyse_nb = NULL ;
u_data - > children = NULL ;
u_data - > num_children = 0 ;
static_assoc . addr_chunk_count = assoc - > addr_chunk_count ;
static_assoc . port1 = assoc - > port1 ;
static_assoc . port2 = assoc - > port2 ;
2005-03-22 10:25:07 +00:00
for ( i = 0 ; i < NUM_CHUNKS ; i + + )
{
2005-05-01 13:55:09 +00:00
static_assoc . chunk_count [ i ] = assoc - > chunk_count [ i ] ;
static_assoc . ep1_chunk_count [ i ] = assoc - > ep1_chunk_count [ i ] ;
static_assoc . ep2_chunk_count [ i ] = assoc - > ep2_chunk_count [ i ] ;
2005-03-22 10:25:07 +00:00
}
2004-09-07 07:54:50 +00:00
set_analyse_child ( u_data ) ;
increase_analyse_childcount ( ) ;
2005-05-01 13:55:09 +00:00
static_assoc . addr_chunk_count = assoc - > addr_chunk_count ;
2004-09-07 07:54:50 +00:00
create_analyse_window ( u_data ) ;
}
2006-06-26 13:18:37 +00:00
static void sctp_analyse_cb ( struct sctp_analyse * u_data , gboolean ext )
2004-09-07 07:54:50 +00:00
{
2007-01-29 20:44:59 +00:00
GList * list , * framelist ;
2005-03-22 10:25:07 +00:00
dfilter_t * sfcode ;
capture_file * cf ;
2009-08-13 19:42:46 +00:00
epan_dissect_t edt ;
2007-01-29 21:26:08 +00:00
gboolean frame_matched , frame_found = FALSE ;
2005-03-22 10:25:07 +00:00
frame_data * fdata ;
gchar filter_text [ 256 ] ;
2005-05-01 13:55:09 +00:00
sctp_assoc_info_t * assoc = NULL ;
2005-03-22 10:25:07 +00:00
int i ;
2007-02-09 21:05:43 +00:00
guint32 * fn ;
2005-03-22 10:25:07 +00:00
2008-02-29 13:33:37 +00:00
g_strlcpy ( filter_text , " sctp " , 250 ) ;
2004-09-07 07:54:50 +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 ) ;
2004-09-07 07:54:50 +00:00
return ;
}
cf = & cfile ;
fdata = cf - > current_frame ;
/* we are on the selected frame now */
if ( fdata = = NULL )
return ; /* if we exit here it's an error */
/* dissect the current frame */
Instead of using a Boolean for the search direction, use an enum, so
that you can tell from examination whether the search is forward or
backward.
Make the cf_find_packet routines take the direction as an explicit
argument, rather than, in the cases where you don't want to permanently
set the direction, saving the direction in the capture_file structure,
changing it, doing the search, and restoring the saved direction. Give
more information in the Doxygen comments for those routines.
Add a cf_find_packet_dfilter_string() routine, which takes a filter
string rather than a compiled filter as an argument. Replace
find_previous_next_frame_with_filter() with it.
Have cf_read_frame_r() and cf_read_frame() pop up the error dialog if
the read fails, rather than leaving that up to its caller. That lets us
eliminate cf_read_error_message(), by swallowing its code into
cf_read_frame_r(). Add Doxygen comments for cf_read_frame_r() and
cf_read_frame().
Don't have find_packet() read the packet before calling the callback
routine; leave that up to the callback routine.
Add cf_find_packet_marked(), to find the next or previous marked packet,
and cf_find_packet_time_reference(), to find the next or previous time
reference packet. Those routines do *not* need to read the packet data
to see if it matches; that lets them run much faster.
Clean up indentation.
svn path=/trunk/; revision=33791
2010-08-13 07:39:46 +00:00
if ( ! cf_read_frame ( cf , fdata ) )
return ; /* error reading the frame */
2004-09-07 07:54:50 +00:00
2009-08-13 19:42:46 +00:00
epan_dissect_init ( & edt , TRUE , FALSE ) ;
epan_dissect_prime_dfilter ( & edt , sfcode ) ;
epan_dissect_run ( & edt , & cf - > pseudo_header , cf - > pd , fdata , NULL ) ;
frame_matched = dfilter_apply_edt ( sfcode , & edt ) ;
2004-09-07 07:54:50 +00:00
/* if it is not an sctp frame, show the dialog */
if ( frame_matched ! = 1 ) {
2009-08-13 19:42:46 +00:00
epan_dissect_cleanup ( & edt ) ;
2004-09-07 07:54:50 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
" Please choose an SCTP packet! " ) ;
return ;
}
list = g_list_first ( sctp_stat_get_info ( ) - > assoc_info_list ) ;
while ( list )
{
assoc = ( sctp_assoc_info_t * ) ( list - > data ) ;
2007-01-29 20:44:59 +00:00
framelist = g_list_first ( assoc - > frame_numbers ) ;
while ( framelist )
{
fn = ( guint32 * ) framelist - > data ;
if ( * fn = = fdata - > num )
2007-01-26 17:27:32 +00:00
{
2007-01-29 20:44:59 +00:00
frame_found = TRUE ;
break ;
2007-01-26 17:27:32 +00:00
}
2007-01-29 20:44:59 +00:00
framelist = g_list_next ( framelist ) ;
2004-09-07 07:54:50 +00:00
}
2007-01-29 20:44:59 +00:00
if ( frame_found )
2005-03-22 10:25:07 +00:00
{
2007-01-29 20:44:59 +00:00
u_data - > assoc = assoc ;
u_data - > assoc - > addr_chunk_count = assoc - > addr_chunk_count ;
static_assoc . addr_chunk_count = assoc - > addr_chunk_count ;
static_assoc . port1 = assoc - > port1 ;
static_assoc . port2 = assoc - > port2 ;
for ( i = 0 ; i < NUM_CHUNKS ; i + + )
2004-09-07 07:54:50 +00:00
{
2007-01-29 20:44:59 +00:00
static_assoc . chunk_count [ i ] = assoc - > chunk_count [ i ] ;
static_assoc . ep1_chunk_count [ i ] = assoc - > ep1_chunk_count [ i ] ;
static_assoc . ep2_chunk_count [ i ] = assoc - > ep2_chunk_count [ i ] ;
2004-09-07 07:54:50 +00:00
}
2007-01-29 20:44:59 +00:00
if ( ext = = FALSE )
create_analyse_window ( u_data ) ;
2004-09-07 07:54:50 +00:00
return ;
}
else
list = g_list_next ( list ) ;
}
2007-01-29 20:44:59 +00:00
if ( ! frame_found )
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Assoc not found! " ) ;
2004-09-07 07:54:50 +00:00
}
2006-11-07 07:47:49 +00:00
void sctp_set_assoc_filter ( void )
2006-06-26 13:18:37 +00:00
{
struct sctp_analyse * u_data ;
/* Register the tap listener */
if ( sctp_stat_get_info ( ) - > is_registered = = FALSE )
register_tap_listener_sctp_stat ( ) ;
/* (redissect all packets) */
sctp_stat_scan ( ) ;
u_data = g_malloc ( sizeof ( struct sctp_analyse ) ) ;
u_data - > assoc = NULL ;
u_data - > children = NULL ;
u_data - > analyse_nb = NULL ;
u_data - > window = NULL ;
u_data - > num_children = 0 ;
2009-06-05 22:42:47 +00:00
cf_retap_packets ( & cfile ) ;
2006-06-26 13:18:37 +00:00
sctp_analyse_cb ( u_data , TRUE ) ;
sctp_set_filter ( NULL , u_data ) ;
}
2004-09-07 07:54:50 +00:00
2011-08-19 14:46:47 +00:00
void sctp_analyse_start ( GtkAction * action _U_ , gpointer user_data _U_ )
2004-09-07 07:54:50 +00:00
{
2005-03-22 10:25:07 +00:00
struct sctp_analyse * u_data ;
2004-09-07 07:54:50 +00:00
/* Register the tap listener */
2005-05-01 13:55:09 +00:00
if ( sctp_stat_get_info ( ) - > is_registered = = FALSE )
2005-03-22 10:25:07 +00:00
register_tap_listener_sctp_stat ( ) ;
/* (redissect all packets) */
2010-08-30 16:10:01 +00:00
2005-03-22 10:25:07 +00:00
sctp_stat_scan ( ) ;
2004-09-07 07:54:50 +00:00
u_data = g_malloc ( sizeof ( struct sctp_analyse ) ) ;
2005-05-01 13:55:09 +00:00
u_data - > assoc = NULL ;
u_data - > children = NULL ;
u_data - > analyse_nb = NULL ;
u_data - > window = NULL ;
u_data - > num_children = 0 ;
2005-03-22 10:25:07 +00:00
2009-06-05 22:42:47 +00:00
cf_retap_packets ( & cfile ) ;
2006-06-26 13:18:37 +00:00
sctp_analyse_cb ( u_data , FALSE ) ;
2004-09-07 07:54:50 +00:00
}
void
register_tap_listener_sctp_analyse ( void )
{
}
2011-09-25 21:19:45 +00:00