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 .
*/
# ifdef HAVE_CONFIG_H
# include <config.h>
# endif
2008-04-13 03:32:24 +00:00
# include <string.h>
2004-09-07 07:54:50 +00:00
# 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"
# include "../simple_dialog.h"
# include "../stat_menu.h"
# include "../register.h"
# include "gtk/gui_stat_menu.h"
# include "gtk/dlg_utils.h"
# include "gtk/gui_utils.h"
# include "gtk/main.h"
# include "gtk/sctp_stat.h"
# include "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
2005-05-01 13:55:09 +00:00
on_destroy ( GtkObject * 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 ) ) ;
2005-05-01 13:55:09 +00:00
list = g_list_previous ( list ) ;
2004-09-07 07:54:50 +00:00
}
g_list_free ( u_data - > children ) ;
u_data - > children = NULL ;
}
2005-03-22 10:25:07 +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-03-22 10:25:07 +00:00
assinfo = g_malloc ( sizeof ( sctp_assoc_info_t ) ) ;
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 ;
2005-03-22 10:25:07 +00:00
assinfo = g_malloc ( sizeof ( sctp_assoc_info_t ) ) ;
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 ;
assinfo = g_malloc ( sizeof ( sctp_assoc_info_t ) ) ;
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 ( 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 * data [ 1 ] ;
gchar field [ 1 ] [ MAX_ADDRESS_LEN ] ;
gint added_row ;
GList * list ;
2005-05-01 13:55:09 +00:00
address * store = NULL ;
2005-03-22 10:25:07 +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 )
{
gtk_clist_clear ( GTK_CLIST ( u_data - > analyse_nb - > page2 - > clist ) ) ;
gtk_clist_clear ( GTK_CLIST ( u_data - > analyse_nb - > page3 - > clist ) ) ;
}
g_snprintf ( label_txt , 50 , " Checksum Type: %s " , u_data - > assoc - > checksum_type ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > checktype ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Checksum Errors: %u " , u_data - > assoc - > n_checksum_errors ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > checksum ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Bundling Errors: %u " , u_data - > assoc - > n_bundling_errors ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > bundling ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Padding Errors: %u " , u_data - > assoc - > n_padding_errors ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > padding ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Length Errors: %u " , u_data - > assoc - > n_length_errors ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > length ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Value Errors: %u " , u_data - > assoc - > n_value_errors ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > value ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " No of Data Chunks from EP1 to EP2: %u " , u_data - > assoc - > n_data_chunks_ep1 ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > chunks_ep1 ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " No of Data Bytes from EP1 to EP2: %u " , u_data - > assoc - > n_data_bytes_ep1 ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > bytes_ep1 ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " No of Data Chunks from EP2 to EP1: %u " , u_data - > assoc - > n_data_chunks_ep2 ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > chunks_ep2 ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " No of Data Bytes from EP2 to EP1: %u " , u_data - > assoc - > n_data_bytes_ep2 ) ;
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-05-01 13:55:09 +00:00
data [ 0 ] = & field [ 0 ] [ 0 ] ;
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 )
2005-03-22 10:25:07 +00:00
{
g_snprintf ( field [ 0 ] , 40 , " %s " , ip6_to_str ( ( const struct e_in6_addr * ) ( store - > data ) ) ) ;
}
added_row = gtk_clist_append ( GTK_CLIST ( u_data - > analyse_nb - > page2 - > clist ) , data ) ;
gtk_clist_set_row_data ( GTK_CLIST ( u_data - > analyse_nb - > page2 - > clist ) , added_row , u_data - > assoc ) ;
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
}
2004-09-07 07:54:50 +00:00
g_snprintf ( label_txt , 50 , " Port: %u " , u_data - > assoc - > port1 ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > port ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Sent Verification Tag: 0x%x " , u_data - > assoc - > verification_tag1 ) ;
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
{
2005-03-22 10:25:07 +00:00
g_snprintf ( label_txt , 50 , " 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 ) ;
g_snprintf ( label_txt , 50 , " Minimum Number of Inbound Streams: %u " , ( ( u_data - > assoc - > instream1 > u_data - > assoc - > outstream2 ) ? u_data - > assoc - > outstream2 : u_data - > assoc - > instream1 ) ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > min_in ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Provided Number of Outbound Streams: %u " , u_data - > assoc - > outstream1 ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > max_out ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Minimum Number of Outbound Streams: %u " , ( ( u_data - > assoc - > outstream1 > u_data - > assoc - > instream2 ) ? u_data - > assoc - > instream2 : u_data - > assoc - > outstream1 ) ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page2 - > max_out ) , label_txt ) ;
}
else
{
2005-03-22 10:25:07 +00:00
g_snprintf ( label_txt , 50 , " 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 ) ;
g_snprintf ( label_txt , 50 , " Used Number of Outbound Streams: %u " , u_data - > assoc - > outstream1 ) ;
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-05-01 13:55:09 +00:00
data [ 0 ] = & field [ 0 ] [ 0 ] ;
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
}
added_row = gtk_clist_append ( GTK_CLIST ( u_data - > analyse_nb - > page3 - > clist ) , data ) ;
gtk_clist_set_row_data ( GTK_CLIST ( u_data - > analyse_nb - > page3 - > clist ) , added_row , u_data - > assoc ) ;
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
g_snprintf ( label_txt , 50 , " Port: %u " , u_data - > assoc - > port2 ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > port ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Sent Verification Tag: 0x%x " , u_data - > assoc - > verification_tag2 ) ;
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
{
2005-03-22 10:25:07 +00:00
g_snprintf ( label_txt , 50 , " 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 ) ;
g_snprintf ( label_txt , 50 , " Minimum Number of Inbound Streams: %u " , ( ( u_data - > assoc - > instream2 > u_data - > assoc - > outstream1 ) ? u_data - > assoc - > outstream1 : u_data - > assoc - > instream2 ) ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > min_in ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Provided Number of Outbound Streams: %u " , u_data - > assoc - > outstream2 ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > max_out ) , label_txt ) ;
g_snprintf ( label_txt , 50 , " Minimum Number of Outbound Streams: %u " , ( ( u_data - > assoc - > outstream2 > u_data - > assoc - > instream1 ) ? u_data - > assoc - > instream1 : u_data - > assoc - > outstream2 ) ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > min_out ) , label_txt ) ;
}
else
{
2005-03-22 10:25:07 +00:00
g_snprintf ( label_txt , 50 , " 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 ) ;
g_snprintf ( label_txt , 50 , " Used Number of Outbound Streams: %u " , u_data - > assoc - > outstream2 ) ;
gtk_label_set_text ( GTK_LABEL ( u_data - > analyse_nb - > page3 - > min_out ) , label_txt ) ;
}
}
2006-06-26 13:18:37 +00:00
void
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 ;
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->verification_tag2,*/
selected_stream - > initiate_tag ,
selected_stream - > verification_tag2 ,
selected_stream - > port2 ,
selected_stream - > port1 ,
selected_stream - > verification_tag2 ,
/*selected_stream->verification_tag1,*/
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 ) ;
}
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 ;
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 ) ;
}
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 ) ;
gtk_container_border_width ( GTK_CONTAINER ( main_vb ) , 2 ) ;
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 ) ;
gtk_button_box_set_spacing ( GTK_BUTTON_BOX ( hbox ) , 0 ) ;
gtk_button_box_set_child_ipadding ( GTK_BUTTON_BOX ( hbox ) , 4 , 0 ) ;
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 ) ;
gtk_container_border_width ( GTK_CONTAINER ( addr_hb ) , 5 ) ;
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
u_data - > analyse_nb - > page2 - > clist = gtk_clist_new ( 1 ) ;
gtk_widget_show ( u_data - > analyse_nb - > page2 - > clist ) ;
gtk_clist_set_column_width ( GTK_CLIST ( u_data - > analyse_nb - > page2 - > clist ) , 0 , 200 ) ;
gtk_clist_set_column_justification ( GTK_CLIST ( u_data - > analyse_nb - > page2 - > clist ) , 0 , GTK_JUSTIFY_LEFT ) ;
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 ) ;
gtk_container_border_width ( GTK_CONTAINER ( hbox ) , 5 ) ;
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 ) ;
gtk_button_box_set_spacing ( GTK_BUTTON_BOX ( h_button_box ) , 0 ) ;
gtk_button_box_set_child_ipadding ( GTK_BUTTON_BOX ( h_button_box ) , 4 , 0 ) ;
gtk_widget_show ( h_button_box ) ;
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 ) ;
gtk_container_border_width ( GTK_CONTAINER ( addr_hb ) , 5 ) ;
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
2004-09-07 07:54:50 +00:00
u_data - > analyse_nb - > page3 - > clist = gtk_clist_new ( 1 ) ;
2005-03-22 10:25:07 +00:00
gtk_widget_show ( u_data - > analyse_nb - > page3 - > clist ) ;
2004-09-07 07:54:50 +00:00
gtk_clist_set_column_width ( GTK_CLIST ( u_data - > analyse_nb - > page3 - > clist ) , 0 , 200 ) ;
gtk_clist_set_column_justification ( GTK_CLIST ( u_data - > analyse_nb - > page3 - > clist ) , 0 , GTK_JUSTIFY_LEFT ) ;
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 ) ;
gtk_container_border_width ( GTK_CONTAINER ( hbox ) , 5 ) ;
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 - > 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 ) ;
2005-03-22 10:25:07 +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 ) ;
gtk_button_box_set_spacing ( GTK_BUTTON_BOX ( h_button_box ) , 0 ) ;
gtk_button_box_set_child_ipadding ( GTK_BUTTON_BOX ( h_button_box ) , 4 , 0 ) ;
gtk_widget_show ( h_button_box ) ;
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 ) ;
2005-03-22 10:25:07 +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
{
2005-03-22 10:25:07 +00:00
guint8 * ip_src ;
guint16 srcport ;
guint8 * ip_dst ;
guint16 dstport ;
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 ;
epan_dissect_t * edt ;
gint err ;
gchar * err_info ;
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 ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , dfilter_error_msg ) ;
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 */
if ( ! wtap_seek_read ( cf - > wth , fdata - > file_off , & cf - > pseudo_header ,
cf - > pd , fdata - > cap_len , & err , & err_info ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
cf_read_error_message ( err , err_info ) , cf - > filename ) ;
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 ) ;
2004-09-07 07:54:50 +00:00
frame_matched = dfilter_apply_edt ( sfcode , edt ) ;
/* if it is not an sctp frame, show the dialog */
if ( frame_matched ! = 1 ) {
epan_dissect_free ( edt ) ;
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
" Please choose an SCTP packet! " ) ;
return ;
}
2007-01-26 17:27:32 +00:00
ip_src = g_malloc ( edt - > pi . net_src . len ) ;
memcpy ( ip_src , edt - > pi . net_src . data , edt - > pi . net_src . len ) ;
ip_dst = g_malloc ( edt - > pi . net_dst . len ) ;
memcpy ( ip_dst , edt - > pi . net_dst . data , edt - > pi . net_dst . len ) ;
2004-09-07 07:54:50 +00:00
srcport = edt - > pi . srcport ;
dstport = edt - > pi . destport ;
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 ;
cf_retap_packets ( & cfile , FALSE ) ;
sctp_analyse_cb ( u_data , TRUE ) ;
sctp_set_filter ( NULL , u_data ) ;
}
2004-09-07 07:54:50 +00:00
void sctp_analyse_start ( GtkWidget * w _U_ , gpointer data _U_ )
{
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) */
2005-02-04 22:45:15 +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
2005-09-14 08:59:41 +00:00
cf_retap_packets ( & cfile , FALSE ) ;
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 )
{
2006-06-26 13:18:37 +00:00
register_stat_menu_item ( " SCTP/Analyse this Association " , REGISTER_STAT_GROUP_TELEPHONY ,
2005-03-22 10:25:07 +00:00
sctp_analyse_start , NULL , NULL , NULL ) ;
2004-09-07 07:54:50 +00:00
}