diff options
author | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2013-06-29 22:01:01 +0000 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2013-06-29 22:01:01 +0000 |
commit | 397ab1dbb752deae2d138ec42e4a903d15563810 (patch) | |
tree | e1c029c67b9d448efb27d3ed36113732c9e6bf58 /ui | |
parent | 1dfecc041c67d8a0525d57827cb7b5842e0ce87d (diff) |
Fix indent (Tabs => Spaces) and add modelines info for follow_* files
svn path=/trunk/; revision=50245
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gtk/follow_ssl.c | 49 | ||||
-rw-r--r-- | ui/gtk/follow_ssl.h | 13 | ||||
-rw-r--r-- | ui/gtk/follow_stream.c | 1637 | ||||
-rw-r--r-- | ui/gtk/follow_stream.h | 104 | ||||
-rw-r--r-- | ui/gtk/follow_tcp.c | 789 | ||||
-rw-r--r-- | ui/gtk/follow_tcp.h | 13 | ||||
-rw-r--r-- | ui/gtk/follow_udp.c | 448 | ||||
-rw-r--r-- | ui/gtk/follow_udp.h | 13 |
8 files changed, 1569 insertions, 1497 deletions
diff --git a/ui/gtk/follow_ssl.c b/ui/gtk/follow_ssl.c index f8b3e3a18f..42a79a6497 100644 --- a/ui/gtk/follow_ssl.c +++ b/ui/gtk/follow_ssl.c @@ -179,13 +179,13 @@ follow_ssl_stream_cb(GtkWidget * w _U_, gpointer data _U_) simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Error creating filter for this stream.\n" "A network layer header is needed"); - g_free(follow_info); + g_free(follow_info); return; } /* Set the display filter entry accordingly */ - filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY); - filter_te = gtk_bin_get_child(GTK_BIN(filter_cm)); + filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY); + filter_te = gtk_bin_get_child(GTK_BIN(filter_cm)); /* needed in follow_filter_out_stream(), is there a better way? */ follow_info->filter_te = filter_te; @@ -211,14 +211,14 @@ follow_ssl_stream_cb(GtkWidget * w _U_, gpointer data _U_) /* data will be passed via tap callback*/ msg = register_tap_listener("ssl", follow_info, follow_filter, 0, - NULL, ssl_queue_packet_data, NULL); + NULL, ssl_queue_packet_data, NULL); if (msg) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't register ssl tap: %s\n",msg->str); - g_free(follow_info->filter_out_filter); - g_free(follow_info); - g_free(follow_filter); + g_free(follow_info->filter_out_filter); + g_free(follow_info); + g_free(follow_filter); return; } gtk_entry_set_text(GTK_ENTRY(filter_te), follow_filter); @@ -236,17 +236,17 @@ follow_ssl_stream_cb(GtkWidget * w _U_, gpointer data _U_) follow_stats(&stats); if (stats.is_ipv6) { - struct e_in6_addr ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 16); - hostname0 = get_hostname6(&ipaddr); - memcpy(&ipaddr, stats.ip_address[0], 16); - hostname1 = get_hostname6(&ipaddr); + struct e_in6_addr ipaddr; + memcpy(&ipaddr, stats.ip_address[0], 16); + hostname0 = get_hostname6(&ipaddr); + memcpy(&ipaddr, stats.ip_address[0], 16); + hostname1 = get_hostname6(&ipaddr); } else { - guint32 ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 4); - hostname0 = get_hostname(ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 4); - hostname1 = get_hostname(ipaddr); + guint32 ipaddr; + memcpy(&ipaddr, stats.ip_address[0], 4); + hostname0 = get_hostname(ipaddr); + memcpy(&ipaddr, stats.ip_address[1], 4); + hostname1 = get_hostname(ipaddr); } port0 = get_tcp_port(stats.port[0]); @@ -283,7 +283,7 @@ follow_ssl_stream_cb(GtkWidget * w _U_, gpointer data _U_) /* Invoke the dialog. */ follow_stream("Follow SSL Stream", follow_info, both_directions_string, - server_to_client_string, client_to_server_string); + server_to_client_string, client_to_server_string); g_free(both_directions_string); g_free(server_to_client_string); @@ -350,3 +350,16 @@ follow_read_ssl_stream(follow_info_t *follow_info, return FRS_OK; } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/gtk/follow_ssl.h b/ui/gtk/follow_ssl.h index ef9027cd32..3f70fb0446 100644 --- a/ui/gtk/follow_ssl.h +++ b/ui/gtk/follow_ssl.h @@ -32,3 +32,16 @@ void follow_ssl_stream_cb(GtkWidget * w, gpointer data _U_); #endif /* __FOLLOW_SSL_H__ */ +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ + diff --git a/ui/gtk/follow_stream.c b/ui/gtk/follow_stream.c index f65ffe4b12..e08ae18420 100644 --- a/ui/gtk/follow_stream.c +++ b/ui/gtk/follow_stream.c @@ -79,58 +79,58 @@ GList *follow_infos = NULL; static frs_return_t follow_read_stream(follow_info_t *follow_info, - gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), - void *arg) + gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), + void *arg) { - switch(follow_info->follow_type) { + switch(follow_info->follow_type) { - case FOLLOW_TCP : - return follow_read_tcp_stream(follow_info, print_line_fcn_p, arg); + case FOLLOW_TCP : + return follow_read_tcp_stream(follow_info, print_line_fcn_p, arg); - case FOLLOW_UDP : - return follow_read_udp_stream(follow_info, print_line_fcn_p, arg); + case FOLLOW_UDP : + return follow_read_udp_stream(follow_info, print_line_fcn_p, arg); - case FOLLOW_SSL : - return follow_read_ssl_stream(follow_info, print_line_fcn_p, arg); + case FOLLOW_SSL : + return follow_read_ssl_stream(follow_info, print_line_fcn_p, arg); - default : - g_assert_not_reached(); - return (frs_return_t)0; - } + default : + g_assert_not_reached(); + return (frs_return_t)0; + } } gboolean follow_add_to_gtk_text(char *buffer, size_t nchars, gboolean is_from_server, - void *arg) + void *arg) { - GtkWidget *text = (GtkWidget *)arg; - GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); - GtkTextIter iter; - - /* While our isprint() hack is in place, we - * have to convert some chars to '.' in order - * to be able to see the data we *should* see - * in the GtkText widget. - */ - size_t i; - - for (i = 0; i < nchars; i++) { - if (buffer[i] == '\n' || buffer[i] == '\r') - continue; - if (! isprint((guchar)buffer[i])) { - buffer[i] = '.'; - } - } - - gtk_text_buffer_get_end_iter(buf, &iter); - if (is_from_server) { - gtk_text_buffer_insert_with_tags(buf, &iter, buffer, (gint) nchars, - server_tag, NULL); - } else { - gtk_text_buffer_insert_with_tags(buf, &iter, buffer, (gint) nchars, - client_tag, NULL); - } - return TRUE; + GtkWidget *text = (GtkWidget *)arg; + GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); + GtkTextIter iter; + + /* While our isprint() hack is in place, we + * have to convert some chars to '.' in order + * to be able to see the data we *should* see + * in the GtkText widget. + */ + size_t i; + + for (i = 0; i < nchars; i++) { + if (buffer[i] == '\n' || buffer[i] == '\r') + continue; + if (! isprint((guchar)buffer[i])) { + buffer[i] = '.'; + } + } + + gtk_text_buffer_get_end_iter(buf, &iter); + if (is_from_server) { + gtk_text_buffer_insert_with_tags(buf, &iter, buffer, (gint) nchars, + server_tag, NULL); + } else { + gtk_text_buffer_insert_with_tags(buf, &iter, buffer, (gint) nchars, + client_tag, NULL); + } + return TRUE; } /* @@ -142,515 +142,514 @@ follow_add_to_gtk_text(char *buffer, size_t nchars, gboolean is_from_server, */ static gboolean follow_print_text(char *buffer, size_t nchars, gboolean is_from_server _U_, - void *arg) + void *arg) { - print_stream_t *stream = (print_stream_t *)arg; - size_t i; - char *str; - - /* convert non printable characters */ - for (i = 0; i < nchars; i++) { - if (buffer[i] == '\n' || buffer[i] == '\r') - continue; - if (! isprint((guchar)buffer[i])) { - buffer[i] = '.'; - } - } - - /* convert unterminated char array to a zero terminated string */ - str = (char *)g_malloc(nchars + 1); - memcpy(str, buffer, nchars); - str[nchars] = 0; - print_line(stream, /*indent*/ 0, str); - g_free(str); - - return TRUE; + print_stream_t *stream = (print_stream_t *)arg; + size_t i; + char *str; + + /* convert non printable characters */ + for (i = 0; i < nchars; i++) { + if (buffer[i] == '\n' || buffer[i] == '\r') + continue; + if (! isprint((guchar)buffer[i])) { + buffer[i] = '.'; + } + } + + /* convert unterminated char array to a zero terminated string */ + str = (char *)g_malloc(nchars + 1); + memcpy(str, buffer, nchars); + str[nchars] = 0; + print_line(stream, /*indent*/ 0, str); + g_free(str); + + return TRUE; } static gboolean follow_write_raw(char *buffer, size_t nchars, gboolean is_from_server _U_, void *arg) { - FILE *fh = (FILE *)arg; - size_t nwritten; + FILE *fh = (FILE *)arg; + size_t nwritten; - nwritten = fwrite(buffer, 1, nchars, fh); - if (nwritten != nchars) - return FALSE; + nwritten = fwrite(buffer, 1, nchars, fh); + if (nwritten != nchars) + return FALSE; - return TRUE; + return TRUE; } /* Handles the display style toggling */ static void follow_charset_toggle_cb(GtkWidget * w _U_, gpointer data) { - follow_info_t *follow_info = (follow_info_t *)data; - - /* - * A radio button toggles when it goes on and when it goes - * off, so when you click a radio button two signals are - * delivered. We only want to reprocess the display once, - * so we do it only when the button goes on. - */ - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { - if (w == follow_info->ebcdic_bt) - follow_info->show_type = SHOW_EBCDIC; - else if (w == follow_info->hexdump_bt) - follow_info->show_type = SHOW_HEXDUMP; - else if (w == follow_info->carray_bt) - follow_info->show_type = SHOW_CARRAY; - else if (w == follow_info->ascii_bt) - follow_info->show_type = SHOW_ASCII; - else if (w == follow_info->raw_bt) - follow_info->show_type = SHOW_RAW; - follow_load_text(follow_info); - } + follow_info_t *follow_info = (follow_info_t *)data; + + /* + * A radio button toggles when it goes on and when it goes + * off, so when you click a radio button two signals are + * delivered. We only want to reprocess the display once, + * so we do it only when the button goes on. + */ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { + if (w == follow_info->ebcdic_bt) + follow_info->show_type = SHOW_EBCDIC; + else if (w == follow_info->hexdump_bt) + follow_info->show_type = SHOW_HEXDUMP; + else if (w == follow_info->carray_bt) + follow_info->show_type = SHOW_CARRAY; + else if (w == follow_info->ascii_bt) + follow_info->show_type = SHOW_ASCII; + else if (w == follow_info->raw_bt) + follow_info->show_type = SHOW_RAW; + follow_load_text(follow_info); + } } void follow_load_text(follow_info_t *follow_info) { - GtkTextBuffer *buf; - - buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(follow_info->text)); - - /* prepare colors one time for repeated use by follow_add_to_gtk_text */ - color_t_to_gdkcolor(&server_fg, &prefs.st_server_fg); - color_t_to_gdkcolor(&server_bg, &prefs.st_server_bg); - color_t_to_gdkcolor(&client_fg, &prefs.st_client_fg); - color_t_to_gdkcolor(&client_bg, &prefs.st_client_bg); - - /* prepare tags one time for repeated use by follow_add_to_gtk_text */ - server_tag = gtk_text_buffer_create_tag(buf, NULL, "foreground-gdk", - &server_fg, "background-gdk", - &server_bg, "font-desc", - user_font_get_regular(), NULL); - client_tag = gtk_text_buffer_create_tag(buf, NULL, "foreground-gdk", - &client_fg, "background-gdk", - &client_bg, "font-desc", - user_font_get_regular(), NULL); - - /* Delete any info already in text box */ - gtk_text_buffer_set_text(buf, "", -1); - - follow_read_stream(follow_info, follow_add_to_gtk_text, - follow_info->text); + GtkTextBuffer *buf; + + buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(follow_info->text)); + + /* prepare colors one time for repeated use by follow_add_to_gtk_text */ + color_t_to_gdkcolor(&server_fg, &prefs.st_server_fg); + color_t_to_gdkcolor(&server_bg, &prefs.st_server_bg); + color_t_to_gdkcolor(&client_fg, &prefs.st_client_fg); + color_t_to_gdkcolor(&client_bg, &prefs.st_client_bg); + + /* prepare tags one time for repeated use by follow_add_to_gtk_text */ + server_tag = gtk_text_buffer_create_tag(buf, NULL, "foreground-gdk", + &server_fg, "background-gdk", + &server_bg, "font-desc", + user_font_get_regular(), NULL); + client_tag = gtk_text_buffer_create_tag(buf, NULL, "foreground-gdk", + &client_fg, "background-gdk", + &client_bg, "font-desc", + user_font_get_regular(), NULL); + + /* Delete any info already in text box */ + gtk_text_buffer_set_text(buf, "", -1); + + follow_read_stream(follow_info, follow_add_to_gtk_text, + follow_info->text); } void follow_filter_out_stream(GtkWidget * w _U_, gpointer data) { - follow_info_t *follow_info = (follow_info_t *)data; + follow_info_t *follow_info = (follow_info_t *)data; - /* Lock out user from messing with us. (ie. don't free our data!) */ - gtk_widget_set_sensitive(follow_info->streamwindow, FALSE); + /* Lock out user from messing with us. (ie. don't free our data!) */ + gtk_widget_set_sensitive(follow_info->streamwindow, FALSE); - /* Set the display filter. */ - gtk_entry_set_text(GTK_ENTRY(follow_info->filter_te), - follow_info->filter_out_filter); + /* Set the display filter. */ + gtk_entry_set_text(GTK_ENTRY(follow_info->filter_te), + follow_info->filter_out_filter); - /* Run the display filter so it goes in effect. */ - main_filter_packets(&cfile, follow_info->filter_out_filter, FALSE); + /* Run the display filter so it goes in effect. */ + main_filter_packets(&cfile, follow_info->filter_out_filter, FALSE); - /* we force a subsequent close */ - window_destroy(follow_info->streamwindow); + /* we force a subsequent close */ + window_destroy(follow_info->streamwindow); - return; + return; } static void follow_find_cb(GtkWidget * w _U_, gpointer data) { - follow_info_t *follow_info = (follow_info_t *)data; - GtkWidget *find_dlg_w, *main_vb, *buttons_row, *find_lb; - GtkWidget *find_hb, *find_text_box, *find_bt, *cancel_bt; - - if (follow_info->find_dlg_w != NULL) { - /* There's already a dialog box; reactivate it. */ - reactivate_window(follow_info->find_dlg_w); - return; - } - - /* Create the find box */ - find_dlg_w = dlg_window_new("Wireshark: Find text"); - gtk_window_set_transient_for(GTK_WINDOW(find_dlg_w), - GTK_WINDOW(follow_info->streamwindow)); - gtk_widget_set_size_request(find_dlg_w, 225, -1); - gtk_window_set_destroy_with_parent(GTK_WINDOW(find_dlg_w), TRUE); - follow_info->find_dlg_w = find_dlg_w; - - g_signal_connect(find_dlg_w, "destroy", G_CALLBACK(follow_find_destroy_cb), - follow_info); - g_signal_connect(find_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), - NULL); - - /* Main vertical box */ - main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5); - gtk_container_add(GTK_CONTAINER(find_dlg_w), main_vb); - - /* Horizontal box for find label, entry field and up/down radio - buttons */ - find_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE); - gtk_box_pack_start(GTK_BOX (main_vb), find_hb, TRUE, TRUE, 0); - gtk_widget_show(find_hb); - - /* Find label */ - find_lb = gtk_label_new("Find text:"); - gtk_box_pack_start(GTK_BOX(find_hb), find_lb, FALSE, FALSE, 0); - gtk_widget_show(find_lb); - - /* Find field */ - find_text_box = gtk_entry_new(); - gtk_box_pack_start(GTK_BOX(find_hb), find_text_box, FALSE, FALSE, 0); - gtk_widget_set_tooltip_text(find_text_box, "Text to search for (case sensitive)"); - gtk_widget_show(find_text_box); - - /* Buttons row */ - buttons_row = dlg_button_row_new(GTK_STOCK_FIND, GTK_STOCK_CANCEL, - NULL); - gtk_box_pack_start(GTK_BOX(main_vb), buttons_row, TRUE, TRUE, 0); - find_bt = (GtkWidget *)g_object_get_data(G_OBJECT(buttons_row), GTK_STOCK_FIND); - cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(buttons_row), GTK_STOCK_CANCEL); - - g_signal_connect(find_bt, "clicked", G_CALLBACK(follow_find_button_cb), follow_info); - g_object_set_data(G_OBJECT(find_bt), "find_string", find_text_box); - window_set_cancel_button(find_dlg_w, cancel_bt, - window_cancel_button_cb); - - /* Hitting return in the find field "clicks" the find button */ - dlg_set_activate(find_text_box, find_bt); - - /* Show the dialog */ - gtk_widget_show_all(find_dlg_w); - window_present(find_dlg_w); + follow_info_t *follow_info = (follow_info_t *)data; + GtkWidget *find_dlg_w, *main_vb, *buttons_row, *find_lb; + GtkWidget *find_hb, *find_text_box, *find_bt, *cancel_bt; + + if (follow_info->find_dlg_w != NULL) { + /* There's already a dialog box; reactivate it. */ + reactivate_window(follow_info->find_dlg_w); + return; + } + + /* Create the find box */ + find_dlg_w = dlg_window_new("Wireshark: Find text"); + gtk_window_set_transient_for(GTK_WINDOW(find_dlg_w), + GTK_WINDOW(follow_info->streamwindow)); + gtk_widget_set_size_request(find_dlg_w, 225, -1); + gtk_window_set_destroy_with_parent(GTK_WINDOW(find_dlg_w), TRUE); + follow_info->find_dlg_w = find_dlg_w; + + g_signal_connect(find_dlg_w, "destroy", G_CALLBACK(follow_find_destroy_cb), + follow_info); + g_signal_connect(find_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), + NULL); + + /* Main vertical box */ + main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); + gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5); + gtk_container_add(GTK_CONTAINER(find_dlg_w), main_vb); + + /* Horizontal box for find label, entry field and up/down radio + buttons */ + find_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE); + gtk_box_pack_start(GTK_BOX (main_vb), find_hb, TRUE, TRUE, 0); + gtk_widget_show(find_hb); + + /* Find label */ + find_lb = gtk_label_new("Find text:"); + gtk_box_pack_start(GTK_BOX(find_hb), find_lb, FALSE, FALSE, 0); + gtk_widget_show(find_lb); + + /* Find field */ + find_text_box = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(find_hb), find_text_box, FALSE, FALSE, 0); + gtk_widget_set_tooltip_text(find_text_box, "Text to search for (case sensitive)"); + gtk_widget_show(find_text_box); + + /* Buttons row */ + buttons_row = dlg_button_row_new(GTK_STOCK_FIND, GTK_STOCK_CANCEL, + NULL); + gtk_box_pack_start(GTK_BOX(main_vb), buttons_row, TRUE, TRUE, 0); + find_bt = (GtkWidget *)g_object_get_data(G_OBJECT(buttons_row), GTK_STOCK_FIND); + cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(buttons_row), GTK_STOCK_CANCEL); + + g_signal_connect(find_bt, "clicked", G_CALLBACK(follow_find_button_cb), follow_info); + g_object_set_data(G_OBJECT(find_bt), "find_string", find_text_box); + window_set_cancel_button(find_dlg_w, cancel_bt, + window_cancel_button_cb); + + /* Hitting return in the find field "clicks" the find button */ + dlg_set_activate(find_text_box, find_bt); + + /* Show the dialog */ + gtk_widget_show_all(find_dlg_w); + window_present(find_dlg_w); } static void follow_find_button_cb(GtkWidget * w, gpointer data) { - gboolean found; - const gchar *find_string; - follow_info_t *follow_info = (follow_info_t *)data; - GtkTextBuffer *buffer; - GtkTextIter iter, match_start, match_end; - GtkTextMark *last_pos_mark; - GtkWidget *find_string_w; - - /* Get the text the user typed into the find field */ - find_string_w = (GtkWidget *)g_object_get_data(G_OBJECT(w), "find_string"); - find_string = gtk_entry_get_text(GTK_ENTRY(find_string_w)); - - /* Get the buffer associated with the follow stream */ - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(follow_info->text)); - gtk_text_buffer_get_start_iter(buffer, &iter); - - /* Look for the search string in the buffer */ - last_pos_mark = gtk_text_buffer_get_mark(buffer, "last_position"); - if(last_pos_mark) - gtk_text_buffer_get_iter_at_mark(buffer, &iter, last_pos_mark); - - found = gtk_text_iter_forward_search(&iter, find_string, (GtkTextSearchFlags)0, - &match_start, - &match_end, - NULL); - - if(found) { - gtk_text_buffer_select_range(buffer, &match_start, &match_end); - last_pos_mark = gtk_text_buffer_create_mark (buffer, - "last_position", - &match_end, FALSE); - gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(follow_info->text), last_pos_mark); - } else { - /* We didn't find a match */ - simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, - "%sFind text has reached the end of the followed " - "stream%s\n\nThe next search will start from the " - "beginning", simple_dialog_primary_start(), - simple_dialog_primary_end()); - if(last_pos_mark) - gtk_text_buffer_delete_mark(buffer, last_pos_mark); - } + gboolean found; + const gchar *find_string; + follow_info_t *follow_info = (follow_info_t *)data; + GtkTextBuffer *buffer; + GtkTextIter iter, match_start, match_end; + GtkTextMark *last_pos_mark; + GtkWidget *find_string_w; + + /* Get the text the user typed into the find field */ + find_string_w = (GtkWidget *)g_object_get_data(G_OBJECT(w), "find_string"); + find_string = gtk_entry_get_text(GTK_ENTRY(find_string_w)); + + /* Get the buffer associated with the follow stream */ + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(follow_info->text)); + gtk_text_buffer_get_start_iter(buffer, &iter); + + /* Look for the search string in the buffer */ + last_pos_mark = gtk_text_buffer_get_mark(buffer, "last_position"); + if(last_pos_mark) + gtk_text_buffer_get_iter_at_mark(buffer, &iter, last_pos_mark); + + found = gtk_text_iter_forward_search(&iter, find_string, (GtkTextSearchFlags)0, + &match_start, + &match_end, + NULL); + + if(found) { + gtk_text_buffer_select_range(buffer, &match_start, &match_end); + last_pos_mark = gtk_text_buffer_create_mark (buffer, + "last_position", + &match_end, FALSE); + gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(follow_info->text), last_pos_mark); + } else { + /* We didn't find a match */ + simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, + "%sFind text has reached the end of the followed " + "stream%s\n\nThe next search will start from the " + "beginning", simple_dialog_primary_start(), + simple_dialog_primary_end()); + if(last_pos_mark) + gtk_text_buffer_delete_mark(buffer, last_pos_mark); + } } static void follow_find_destroy_cb(GtkWidget * win _U_, gpointer data) { - follow_info_t *follow_info = (follow_info_t *)data; + follow_info_t *follow_info = (follow_info_t *)data; - /* Note that we no longer have a dialog box. */ - follow_info->find_dlg_w = NULL; + /* Note that we no longer have a dialog box. */ + follow_info->find_dlg_w = NULL; } static void follow_print_stream(GtkWidget * w _U_, gpointer data) { - print_stream_t *stream; - gboolean to_file; - const char *print_dest; - follow_info_t *follow_info =(follow_info_t *) data; + print_stream_t *stream; + gboolean to_file; + const char *print_dest; + follow_info_t *follow_info =(follow_info_t *) data; #ifdef _WIN32 - gboolean win_printer = FALSE; - int tmp_fd; - char *tmp_namebuf; + gboolean win_printer = FALSE; + int tmp_fd; + char *tmp_namebuf; #endif - switch (prefs.pr_dest) { - case PR_DEST_CMD: + switch (prefs.pr_dest) { + case PR_DEST_CMD: #ifdef _WIN32 - win_printer = TRUE; - /* (The code for creating a temp filename is adapted from print_dlg.c). */ - /* We currently don't have a function in util.h to create just a tempfile */ - /* name, so simply create a tempfile using the "official" function, */ - /* then delete this file again. After this, the name MUST be available. */ - /* */ - /* Don't use tmpnam() or such, as this will fail under some ACL */ - /* circumstances: http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=358 */ - /* Also: tmpnam is "insecure" and should not be used. */ - tmp_fd = create_tempfile(&tmp_namebuf, "wshprint"); - if(tmp_fd == -1) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Couldn't create temporary file for printing:\n%s", tmp_namebuf); - return; - } - ws_close(tmp_fd); - ws_unlink(tmp_namebuf); - print_dest = tmp_namebuf; - to_file = TRUE; + win_printer = TRUE; + /* (The code for creating a temp filename is adapted from print_dlg.c). */ + /* We currently don't have a function in util.h to create just a tempfile */ + /* name, so simply create a tempfile using the "official" function, */ + /* then delete this file again. After this, the name MUST be available. */ + /* */ + /* Don't use tmpnam() or such, as this will fail under some ACL */ + /* circumstances: http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=358 */ + /* Also: tmpnam is "insecure" and should not be used. */ + tmp_fd = create_tempfile(&tmp_namebuf, "wshprint"); + if(tmp_fd == -1) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Couldn't create temporary file for printing:\n%s", tmp_namebuf); + return; + } + ws_close(tmp_fd); + ws_unlink(tmp_namebuf); + print_dest = tmp_namebuf; + to_file = TRUE; #else - print_dest = prefs.pr_cmd; - to_file = FALSE; + print_dest = prefs.pr_cmd; + to_file = FALSE; #endif - break; - case PR_DEST_FILE: - print_dest = prefs.pr_file; - to_file = TRUE; - break; - default: /* "Can't happen" */ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Couldn't figure out where to send the print " - "job. Check your preferences."); - return; - } - - switch (prefs.pr_format) { - - case PR_FMT_TEXT: - stream = print_stream_text_new(to_file, print_dest); - break; - - case PR_FMT_PS: - stream = print_stream_ps_new(to_file, print_dest); - break; - - default: - g_assert_not_reached(); - stream = NULL; - } - if (stream == NULL) { - if (to_file) { - open_failure_alert_box(print_dest, errno, TRUE); - } else { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Couldn't run print command %s.", - prefs.pr_cmd); - } - return; - } - - if (!print_preamble(stream, cfile.filename)) - goto print_error; - - switch (follow_read_stream(follow_info, follow_print_text, stream)) { - case FRS_OK: - break; - case FRS_OPEN_ERROR: - case FRS_READ_ERROR: - /* XXX - cancel printing? */ - destroy_print_stream(stream); - return; - case FRS_PRINT_ERROR: - goto print_error; - } - - if (!print_finale(stream)) - goto print_error; - - if (!destroy_print_stream(stream)) { - if (to_file) { - write_failure_alert_box(print_dest, errno); - } else { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Error closing print destination."); - } - } + break; + case PR_DEST_FILE: + print_dest = prefs.pr_file; + to_file = TRUE; + break; + default: /* "Can't happen" */ + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Couldn't figure out where to send the print " + "job. Check your preferences."); + return; + } + + switch (prefs.pr_format) { + + case PR_FMT_TEXT: + stream = print_stream_text_new(to_file, print_dest); + break; + + case PR_FMT_PS: + stream = print_stream_ps_new(to_file, print_dest); + break; + + default: + g_assert_not_reached(); + stream = NULL; + } + if (stream == NULL) { + if (to_file) { + open_failure_alert_box(print_dest, errno, TRUE); + } else { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Couldn't run print command %s.", + prefs.pr_cmd); + } + return; + } + + if (!print_preamble(stream, cfile.filename)) + goto print_error; + + switch (follow_read_stream(follow_info, follow_print_text, stream)) { + case FRS_OK: + break; + case FRS_OPEN_ERROR: + case FRS_READ_ERROR: + /* XXX - cancel printing? */ + destroy_print_stream(stream); + return; + case FRS_PRINT_ERROR: + goto print_error; + } + + if (!print_finale(stream)) + goto print_error; + + if (!destroy_print_stream(stream)) { + if (to_file) { + write_failure_alert_box(print_dest, errno); + } else { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Error closing print destination."); + } + } #ifdef _WIN32 - if (win_printer) { - print_mswin(print_dest); + if (win_printer) { + print_mswin(print_dest); - /* trash temp file */ - ws_remove(print_dest); - } + /* trash temp file */ + ws_remove(print_dest); + } #endif - return; + return; print_error: - if (to_file) { - write_failure_alert_box(print_dest, errno); - } else { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Error writing to print command: %s", - g_strerror(errno)); - } - /* XXX - cancel printing? */ - destroy_print_stream(stream); + if (to_file) { + write_failure_alert_box(print_dest, errno); + } else { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Error writing to print command: %s", + g_strerror(errno)); + } + /* XXX - cancel printing? */ + destroy_print_stream(stream); #ifdef _WIN32 - if (win_printer) { - /* trash temp file */ - ws_remove(print_dest); - } + if (win_printer) { + /* trash temp file */ + ws_remove(print_dest); + } #endif } static char * gtk_follow_save_as_file(GtkWidget *caller) { - GtkWidget *new_win; - char *pathname; - - new_win = file_selection_new("Wireshark: Save Follow Stream As", - GTK_WINDOW(caller), - FILE_SELECTION_SAVE); - pathname = file_selection_run(new_win); - if (pathname == NULL) { - /* User cancelled or closed the dialog. */ - return NULL; - } - - /* We've crosed the Rubicon; get rid of the dialog box. */ - window_destroy(new_win); - - return pathname; + GtkWidget *new_win; + char *pathname; + + new_win = file_selection_new("Wireshark: Save Follow Stream As", + GTK_WINDOW(caller), + FILE_SELECTION_SAVE); + pathname = file_selection_run(new_win); + if (pathname == NULL) { + /* User cancelled or closed the dialog. */ + return NULL; + } + + /* We've crosed the Rubicon; get rid of the dialog box. */ + window_destroy(new_win); + + return pathname; } static gboolean follow_save_as_ok_cb(gchar *to_name, follow_info_t *follow_info) { - FILE *fh; - print_stream_t *stream; - - if (follow_info->show_type == SHOW_RAW) { - /* Write the data out as raw binary data */ - fh = ws_fopen(to_name, "wb"); - } else { - /* Write it out as text */ - fh = ws_fopen(to_name, "w"); - } - if (fh == NULL) { - open_failure_alert_box(to_name, errno, TRUE); - return FALSE; - } - - if (follow_info->show_type == SHOW_RAW) { - switch (follow_read_stream(follow_info, follow_write_raw, fh)) { - case FRS_OK: - if (fclose(fh) == EOF) { - write_failure_alert_box(to_name, errno); - return FALSE; - } - break; - - case FRS_OPEN_ERROR: - case FRS_READ_ERROR: - fclose(fh); - return FALSE; - - case FRS_PRINT_ERROR: - write_failure_alert_box(to_name, errno); - fclose(fh); - return FALSE; - } - } else { - stream = print_stream_text_stdio_new(fh); - switch (follow_read_stream(follow_info, follow_print_text, - stream)) { - case FRS_OK: - if (!destroy_print_stream(stream)) { - write_failure_alert_box(to_name, errno); - return FALSE; - } - break; - - case FRS_OPEN_ERROR: - case FRS_READ_ERROR: - destroy_print_stream(stream); - return FALSE; - - case FRS_PRINT_ERROR: - write_failure_alert_box(to_name, errno); - destroy_print_stream(stream); - return FALSE; - } - } - - return TRUE; + FILE *fh; + print_stream_t *stream; + + if (follow_info->show_type == SHOW_RAW) { + /* Write the data out as raw binary data */ + fh = ws_fopen(to_name, "wb"); + } else { + /* Write it out as text */ + fh = ws_fopen(to_name, "w"); + } + if (fh == NULL) { + open_failure_alert_box(to_name, errno, TRUE); + return FALSE; + } + + if (follow_info->show_type == SHOW_RAW) { + switch (follow_read_stream(follow_info, follow_write_raw, fh)) { + case FRS_OK: + if (fclose(fh) == EOF) { + write_failure_alert_box(to_name, errno); + return FALSE; + } + break; + + case FRS_OPEN_ERROR: + case FRS_READ_ERROR: + fclose(fh); + return FALSE; + + case FRS_PRINT_ERROR: + write_failure_alert_box(to_name, errno); + fclose(fh); + return FALSE; + } + } else { + stream = print_stream_text_stdio_new(fh); + switch (follow_read_stream(follow_info, follow_print_text, stream)) { + case FRS_OK: + if (!destroy_print_stream(stream)) { + write_failure_alert_box(to_name, errno); + return FALSE; + } + break; + + case FRS_OPEN_ERROR: + case FRS_READ_ERROR: + destroy_print_stream(stream); + return FALSE; + + case FRS_PRINT_ERROR: + write_failure_alert_box(to_name, errno); + destroy_print_stream(stream); + return FALSE; + } + } + + return TRUE; } static void follow_save_as_cmd_cb(GtkWidget *w, gpointer data) { - GtkWidget *caller = gtk_widget_get_toplevel(w); - follow_info_t *follow_info = (follow_info_t *)data; - char *pathname; - - /* - * Loop until the user either selects a file or gives up. - */ - for (;;) { - pathname = gtk_follow_save_as_file(caller); - if (pathname == NULL) { - /* User gave up. */ - break; - } - if (follow_save_as_ok_cb(pathname, follow_info)) { - /* We succeeded. */ - g_free(pathname); - break; - } - /* Dump failed; let the user select another file or give up. */ - g_free(pathname); - } + GtkWidget *caller = gtk_widget_get_toplevel(w); + follow_info_t *follow_info = (follow_info_t *)data; + char *pathname; + + /* + * Loop until the user either selects a file or gives up. + */ + for (;;) { + pathname = gtk_follow_save_as_file(caller); + if (pathname == NULL) { + /* User gave up. */ + break; + } + if (follow_save_as_ok_cb(pathname, follow_info)) { + /* We succeeded. */ + g_free(pathname); + break; + } + /* Dump failed; let the user select another file or give up. */ + g_free(pathname); + } } static void follow_stream_direction_changed(GtkWidget *w, gpointer data) { - follow_info_t *follow_info = (follow_info_t *)data; - - switch(gtk_combo_box_get_active(GTK_COMBO_BOX(w))) { - - case 0 : - follow_info->show_stream = BOTH_HOSTS; - follow_load_text(follow_info); - break; - case 1 : - follow_info->show_stream = FROM_SERVER; - follow_load_text(follow_info); - break; - case 2 : - follow_info->show_stream = FROM_CLIENT; - follow_load_text(follow_info); - break; - } + follow_info_t *follow_info = (follow_info_t *)data; + + switch(gtk_combo_box_get_active(GTK_COMBO_BOX(w))) { + + case 0 : + follow_info->show_stream = BOTH_HOSTS; + follow_load_text(follow_info); + break; + case 1 : + follow_info->show_stream = FROM_SERVER; + follow_load_text(follow_info); + break; + case 2 : + follow_info->show_stream = FROM_CLIENT; + follow_load_text(follow_info); + break; + } } /* Add a "follow_info_t" structure to the list. */ static void remember_follow_info(follow_info_t *follow_info) { - follow_infos = g_list_append(follow_infos, follow_info); + follow_infos = g_list_append(follow_infos, follow_info); } #define IS_SHOW_TYPE(x) (follow_info->show_type == x ? 1 : 0) @@ -658,218 +657,194 @@ remember_follow_info(follow_info_t *follow_info) static void forget_follow_info(follow_info_t *follow_info) { - follow_infos = g_list_remove(follow_infos, follow_info); + follow_infos = g_list_remove(follow_infos, follow_info); } void follow_stream(const gchar *title, follow_info_t *follow_info, - gchar *both_directions_string, - gchar *server_to_client_string, gchar *client_to_server_string) + gchar *both_directions_string, + gchar *server_to_client_string, gchar *client_to_server_string) { - GtkWidget *streamwindow, *vbox, *txt_scrollw, *text; - GtkWidget *hbox, *bbox, *button, *radio_bt; - GtkWidget *stream_fr, *stream_vb, *direction_hbox; - GtkWidget *stream_cmb; - follow_stats_t stats; - - follow_info->show_type = SHOW_RAW; - - streamwindow = dlg_window_new(title); - - /* needed in follow_filter_out_stream(), is there a better way? */ - follow_info->streamwindow = streamwindow; - - gtk_widget_set_name(streamwindow, title); - gtk_window_set_default_size(GTK_WINDOW(streamwindow), - DEF_WIDTH, DEF_HEIGHT); - gtk_container_set_border_width(GTK_CONTAINER(streamwindow), 6); - - /* setup the container */ - vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - gtk_container_add(GTK_CONTAINER(streamwindow), vbox); - - /* content frame */ - if (incomplete_tcp_stream) { - stream_fr = gtk_frame_new("Stream Content (incomplete)"); - } else { - stream_fr = gtk_frame_new("Stream Content"); - } - gtk_box_pack_start(GTK_BOX (vbox), stream_fr, TRUE, TRUE, 0); - gtk_widget_show(stream_fr); - - stream_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - gtk_container_set_border_width( GTK_CONTAINER(stream_vb) , 6); - gtk_container_add(GTK_CONTAINER(stream_fr), stream_vb); - - /* create a scrolled window for the text */ - txt_scrollw = scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scrollw), - GTK_SHADOW_IN); - gtk_box_pack_start(GTK_BOX(stream_vb), txt_scrollw, TRUE, TRUE, 0); - - /* create a text box */ - text = gtk_text_view_new(); - gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD_CHAR); - - gtk_container_add(GTK_CONTAINER(txt_scrollw), text); - follow_info->text = text; - - /* direction hbox */ - direction_hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE); - gtk_box_pack_start(GTK_BOX(stream_vb), direction_hbox, FALSE, FALSE, 0); - - stream_cmb = gtk_combo_box_text_new(); - - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(stream_cmb), - both_directions_string); - follow_info->show_stream = BOTH_HOSTS; - - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(stream_cmb), - server_to_client_string); - - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(stream_cmb), - client_to_server_string); - - gtk_combo_box_set_active(GTK_COMBO_BOX(stream_cmb), 0); /* Do this before signal_connect */ - /* so callback not triggered */ - - g_signal_connect(stream_cmb, "changed", - G_CALLBACK(follow_stream_direction_changed), - follow_info); - - gtk_widget_set_tooltip_text(stream_cmb, "Select the stream direction to display"); - gtk_box_pack_start(GTK_BOX(direction_hbox), stream_cmb, TRUE, TRUE, 0); - - /* stream hbox */ - hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE); - gtk_box_pack_start(GTK_BOX(stream_vb), hbox, FALSE, FALSE, 0); - - /* Create Find Button */ - button = gtk_button_new_from_stock(GTK_STOCK_FIND); - g_signal_connect(button, "clicked", G_CALLBACK(follow_find_cb), follow_info); - gtk_widget_set_tooltip_text(button, "Find text in the displayed content"); - gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); - - /* Create Save As Button */ - button = gtk_button_new_from_stock(GTK_STOCK_SAVE_AS); - g_signal_connect(button, "clicked", G_CALLBACK(follow_save_as_cmd_cb), follow_info); - gtk_widget_set_tooltip_text(button, "Save the content as currently displayed"); - gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); - - /* Create Print Button */ - button = gtk_button_new_from_stock(GTK_STOCK_PRINT); - g_signal_connect(button, "clicked", G_CALLBACK(follow_print_stream), follow_info); - gtk_widget_set_tooltip_text(button, "Print the content as currently displayed"); - gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); - - /* Stream to show */ - follow_stats(&stats); - - follow_info->is_ipv6 = stats.is_ipv6; - - /* ASCII radio button */ - radio_bt = gtk_radio_button_new_with_label(NULL, "ASCII"); - gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"ASCII\" format"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), - IS_SHOW_TYPE(SHOW_ASCII)); - gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); - g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb), - follow_info); - follow_info->ascii_bt = radio_bt; - - /* EBCDIC radio button */ - radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group - (GTK_RADIO_BUTTON(radio_bt)), - "EBCDIC"); - gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"EBCDIC\" format"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), - IS_SHOW_TYPE(SHOW_EBCDIC)); - gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); - g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb), - follow_info); - follow_info->ebcdic_bt = radio_bt; - - /* HEX DUMP radio button */ - radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group - (GTK_RADIO_BUTTON(radio_bt)), - "Hex Dump"); - gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"Hexdump\" format"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), - IS_SHOW_TYPE(SHOW_HEXDUMP)); - gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); - g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb), - follow_info); - follow_info->hexdump_bt = radio_bt; - - /* C Array radio button */ - radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group - (GTK_RADIO_BUTTON(radio_bt)), - "C Arrays"); - gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"C Array\" format"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), - IS_SHOW_TYPE(SHOW_CARRAY)); - gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); - g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb), - follow_info); - follow_info->carray_bt = radio_bt; - - /* Raw radio button */ - radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group - (GTK_RADIO_BUTTON(radio_bt)), - "Raw"); - gtk_widget_set_tooltip_text(radio_bt, + GtkWidget *streamwindow, *vbox, *txt_scrollw, *text; + GtkWidget *hbox, *bbox, *button, *radio_bt; + GtkWidget *stream_fr, *stream_vb, *direction_hbox; + GtkWidget *stream_cmb; + follow_stats_t stats; + + follow_info->show_type = SHOW_RAW; + + streamwindow = dlg_window_new(title); + + /* needed in follow_filter_out_stream(), is there a better way? */ + follow_info->streamwindow = streamwindow; + + gtk_widget_set_name(streamwindow, title); + gtk_window_set_default_size(GTK_WINDOW(streamwindow), DEF_WIDTH, DEF_HEIGHT); + gtk_container_set_border_width(GTK_CONTAINER(streamwindow), 6); + + /* setup the container */ + vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); + gtk_container_add(GTK_CONTAINER(streamwindow), vbox); + + /* content frame */ + if (incomplete_tcp_stream) { + stream_fr = gtk_frame_new("Stream Content (incomplete)"); + } else { + stream_fr = gtk_frame_new("Stream Content"); + } + gtk_box_pack_start(GTK_BOX (vbox), stream_fr, TRUE, TRUE, 0); + gtk_widget_show(stream_fr); + + stream_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); + gtk_container_set_border_width( GTK_CONTAINER(stream_vb) , 6); + gtk_container_add(GTK_CONTAINER(stream_fr), stream_vb); + + /* create a scrolled window for the text */ + txt_scrollw = scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scrollw), GTK_SHADOW_IN); + gtk_box_pack_start(GTK_BOX(stream_vb), txt_scrollw, TRUE, TRUE, 0); + + /* create a text box */ + text = gtk_text_view_new(); + gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); + gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD_CHAR); + + gtk_container_add(GTK_CONTAINER(txt_scrollw), text); + follow_info->text = text; + + /* direction hbox */ + direction_hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE); + gtk_box_pack_start(GTK_BOX(stream_vb), direction_hbox, FALSE, FALSE, 0); + + stream_cmb = gtk_combo_box_text_new(); + + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(stream_cmb), both_directions_string); + follow_info->show_stream = BOTH_HOSTS; + + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(stream_cmb), server_to_client_string); + + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(stream_cmb), client_to_server_string); + + gtk_combo_box_set_active(GTK_COMBO_BOX(stream_cmb), 0); /* Do this before signal_connect */ + /* so callback not triggered */ + + g_signal_connect(stream_cmb, "changed", G_CALLBACK(follow_stream_direction_changed), follow_info); + + gtk_widget_set_tooltip_text(stream_cmb, "Select the stream direction to display"); + gtk_box_pack_start(GTK_BOX(direction_hbox), stream_cmb, TRUE, TRUE, 0); + + /* stream hbox */ + hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE); + gtk_box_pack_start(GTK_BOX(stream_vb), hbox, FALSE, FALSE, 0); + + /* Create Find Button */ + button = gtk_button_new_from_stock(GTK_STOCK_FIND); + g_signal_connect(button, "clicked", G_CALLBACK(follow_find_cb), follow_info); + gtk_widget_set_tooltip_text(button, "Find text in the displayed content"); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + + /* Create Save As Button */ + button = gtk_button_new_from_stock(GTK_STOCK_SAVE_AS); + g_signal_connect(button, "clicked", G_CALLBACK(follow_save_as_cmd_cb), follow_info); + gtk_widget_set_tooltip_text(button, "Save the content as currently displayed"); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + + /* Create Print Button */ + button = gtk_button_new_from_stock(GTK_STOCK_PRINT); + g_signal_connect(button, "clicked", G_CALLBACK(follow_print_stream), follow_info); + gtk_widget_set_tooltip_text(button, "Print the content as currently displayed"); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + + /* Stream to show */ + follow_stats(&stats); + + follow_info->is_ipv6 = stats.is_ipv6; + + /* ASCII radio button */ + radio_bt = gtk_radio_button_new_with_label(NULL, "ASCII"); + gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"ASCII\" format"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), IS_SHOW_TYPE(SHOW_ASCII)); + gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); + g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb), follow_info); + follow_info->ascii_bt = radio_bt; + + /* EBCDIC radio button */ + radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_bt)), + "EBCDIC"); + gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"EBCDIC\" format"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), IS_SHOW_TYPE(SHOW_EBCDIC)); + gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); + g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb), follow_info); + follow_info->ebcdic_bt = radio_bt; + + /* HEX DUMP radio button */ + radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_bt)), + "Hex Dump"); + gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"Hexdump\" format"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), IS_SHOW_TYPE(SHOW_HEXDUMP)); + gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); + g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb),follow_info); + follow_info->hexdump_bt = radio_bt; + + /* C Array radio button */ + radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_bt)), + "C Arrays"); + gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"C Array\" format"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), IS_SHOW_TYPE(SHOW_CARRAY)); + gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); + g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb), follow_info); + follow_info->carray_bt = radio_bt; + + /* Raw radio button */ + radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_bt)), + "Raw"); + gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"Raw\" (binary) format. " "As this contains non printable characters, " "the screen output will be in ASCII format"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), - IS_SHOW_TYPE(SHOW_RAW)); - gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); - g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb), - follow_info); - follow_info->raw_bt = radio_bt; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt), IS_SHOW_TYPE(SHOW_RAW)); + gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0); + g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb), follow_info); + follow_info->raw_bt = radio_bt; - /* Button row: help, filter out, close button */ - bbox = dlg_button_row_new(WIRESHARK_STOCK_FILTER_OUT_STREAM, - GTK_STOCK_CLOSE, GTK_STOCK_HELP, - NULL); - gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); + /* Button row: help, filter out, close button */ + bbox = dlg_button_row_new(WIRESHARK_STOCK_FILTER_OUT_STREAM, GTK_STOCK_CLOSE, GTK_STOCK_HELP, + NULL); + gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); - button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_FILTER_OUT_STREAM); - gtk_widget_set_tooltip_text(button, "Build a display filter which cuts this stream from the capture"); - g_signal_connect(button, "clicked", G_CALLBACK(follow_filter_out_stream), - follow_info); + button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_FILTER_OUT_STREAM); + gtk_widget_set_tooltip_text(button, "Build a display filter which cuts this stream from the capture"); + g_signal_connect(button, "clicked", G_CALLBACK(follow_filter_out_stream), follow_info); - button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(streamwindow, button, window_cancel_button_cb); - gtk_widget_set_tooltip_text(button, "Close the dialog and keep the current display filter"); - gtk_widget_grab_default(button); + button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); + window_set_cancel_button(streamwindow, button, window_cancel_button_cb); + gtk_widget_set_tooltip_text(button, "Close the dialog and keep the current display filter"); + gtk_widget_grab_default(button); - button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP); - g_signal_connect(button, "clicked", G_CALLBACK(topic_cb), - (gpointer)HELP_FOLLOW_STREAM_DIALOG); + button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP); + g_signal_connect(button, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_FOLLOW_STREAM_DIALOG); - /* Tuck away the follow_info object into the window */ - g_object_set_data(G_OBJECT(streamwindow), E_FOLLOW_INFO_KEY, follow_info); + /* Tuck away the follow_info object into the window */ + g_object_set_data(G_OBJECT(streamwindow), E_FOLLOW_INFO_KEY, follow_info); - follow_load_text(follow_info); - remember_follow_info(follow_info); + follow_load_text(follow_info); + remember_follow_info(follow_info); - g_signal_connect(streamwindow, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(streamwindow, "destroy", G_CALLBACK(follow_destroy_cb), NULL); + g_signal_connect(streamwindow, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); + g_signal_connect(streamwindow, "destroy", G_CALLBACK(follow_destroy_cb), NULL); - /* Make sure this widget gets destroyed if we quit the main loop, - so that if we exit, we clean up any temporary files we have - for "Follow TCP Stream" windows. + /* Make sure this widget gets destroyed if we quit the main loop, + so that if we exit, we clean up any temporary files we have + for "Follow TCP Stream" windows. gtk_quit_add_destroy is deprecated and should not be used in newly-written code. This function is going to be removed in GTK+ 3.0 gtk_quit_add_destroy(gtk_main_level(), GTK_OBJECT(streamwindow)); - */ + */ - gtk_widget_show_all(streamwindow); - window_present(streamwindow); + gtk_widget_show_all(streamwindow); + window_present(streamwindow); } /* The destroy call back has the responsibility of @@ -878,185 +853,195 @@ follow_stream(const gchar *title, follow_info_t *follow_info, static void follow_destroy_cb(GtkWidget *w, gpointer data _U_) { - follow_info_t *follow_info; - follow_record_t *follow_record; - GList *cur; - int i; - - follow_info = (follow_info_t *)g_object_get_data(G_OBJECT(w), E_FOLLOW_INFO_KEY); - - switch(follow_info->follow_type) { - - case FOLLOW_TCP : - i = ws_unlink(follow_info->data_out_filename); - if(i != 0) { - g_warning("Follow: Couldn't remove temporary file: \"%s\", errno: %s (%u)", - follow_info->data_out_filename, g_strerror(errno), errno); - } - break; - - case FOLLOW_UDP : - for(cur = follow_info->payload; cur; cur = g_list_next(cur)) - if(cur->data) { - follow_record = (follow_record_t *)cur->data; - if(follow_record->data) - g_byte_array_free(follow_record->data, - TRUE); - - g_free(follow_record); - } - - g_list_free(follow_info->payload); - break; - - case FOLLOW_SSL : - /* free decrypted data list*/ - for (cur = follow_info->payload; cur; cur = g_list_next(cur)) - if (cur->data) - { - g_free(cur->data); - cur->data = NULL; - } - g_list_free (follow_info->payload); - break; - } - - g_free(follow_info->data_out_filename); - g_free(follow_info->filter_out_filter); - g_free((gpointer)follow_info->client_ip.data); - forget_follow_info(follow_info); - g_free(follow_info); - gtk_widget_destroy(w); + follow_info_t *follow_info; + follow_record_t *follow_record; + GList *cur; + int i; + + follow_info = (follow_info_t *)g_object_get_data(G_OBJECT(w), E_FOLLOW_INFO_KEY); + + switch(follow_info->follow_type) { + + case FOLLOW_TCP : + i = ws_unlink(follow_info->data_out_filename); + if(i != 0) { + g_warning("Follow: Couldn't remove temporary file: \"%s\", errno: %s (%u)", + follow_info->data_out_filename, g_strerror(errno), errno); + } + break; + + case FOLLOW_UDP : + for(cur = follow_info->payload; cur; cur = g_list_next(cur)) + if(cur->data) { + follow_record = (follow_record_t *)cur->data; + if(follow_record->data) + g_byte_array_free(follow_record->data, TRUE); + + g_free(follow_record); + } + + g_list_free(follow_info->payload); + break; + + case FOLLOW_SSL : + /* free decrypted data list*/ + for (cur = follow_info->payload; cur; cur = g_list_next(cur)) + if (cur->data) + { + g_free(cur->data); + cur->data = NULL; + } + g_list_free (follow_info->payload); + break; + } + + g_free(follow_info->data_out_filename); + g_free(follow_info->filter_out_filter); + g_free((gpointer)follow_info->client_ip.data); + forget_follow_info(follow_info); + g_free(follow_info); + gtk_widget_destroy(w); } frs_return_t follow_show(follow_info_t *follow_info, - gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), - char *buffer, size_t nchars, gboolean is_from_server, void *arg, - guint32 *global_pos, guint32 *server_packet_count, - guint32 *client_packet_count) + gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), + char *buffer, size_t nchars, gboolean is_from_server, void *arg, + guint32 *global_pos, guint32 *server_packet_count, + guint32 *client_packet_count) { - gchar initbuf[256]; - guint32 current_pos; - static const gchar hexchars[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; - - switch (follow_info->show_type) { - - case SHOW_EBCDIC: - /* If our native arch is ASCII, call: */ - EBCDIC_to_ASCII(buffer, (guint) nchars); - if (!(*print_line_fcn_p) (buffer, nchars, is_from_server, arg)) - return FRS_PRINT_ERROR; - break; - - case SHOW_ASCII: - /* If our native arch is EBCDIC, call: - * ASCII_TO_EBCDIC(buffer, nchars); - */ - if (!(*print_line_fcn_p) (buffer, nchars, is_from_server, arg)) - return FRS_PRINT_ERROR; - break; - - case SHOW_RAW: - /* Don't translate, no matter what the native arch - * is. - */ - if (!(*print_line_fcn_p) (buffer, nchars, is_from_server, arg)) - return FRS_PRINT_ERROR; - break; - - case SHOW_HEXDUMP: - current_pos = 0; - while (current_pos < nchars) { - gchar hexbuf[256]; - int i; - gchar *cur = hexbuf, *ascii_start; - - /* is_from_server indentation : put 4 spaces at the - * beginning of the string */ - /* XXX - We might want to prepend each line with "C" or "S" instead. */ - if (is_from_server && follow_info->show_stream == BOTH_HOSTS) { - memset(cur, ' ', 4); - cur += 4; - } - cur += g_snprintf(cur, 20, "%08X ", *global_pos); - /* 49 is space consumed by hex chars */ - ascii_start = cur + 49; - for (i = 0; i < 16 && current_pos + i < nchars; i++) { - *cur++ = - hexchars[(buffer[current_pos + i] & 0xf0) >> 4]; - *cur++ = - hexchars[buffer[current_pos + i] & 0x0f]; - *cur++ = ' '; - if (i == 7) - *cur++ = ' '; - } - /* Fill it up if column isn't complete */ - while (cur < ascii_start) - *cur++ = ' '; - - /* Now dump bytes as text */ - for (i = 0; i < 16 && current_pos + i < nchars; i++) { - *cur++ = - (isprint((guchar)buffer[current_pos + i]) ? - buffer[current_pos + i] : '.' ); - if (i == 7) { - *cur++ = ' '; - } - } - current_pos += i; - (*global_pos) += i; - *cur++ = '\n'; - *cur = 0; - if (!(*print_line_fcn_p) (hexbuf, strlen(hexbuf), is_from_server, arg)) - return FRS_PRINT_ERROR; - } - break; - - case SHOW_CARRAY: - current_pos = 0; - g_snprintf(initbuf, sizeof(initbuf), "char peer%d_%d[] = {\n", - is_from_server ? 1 : 0, - is_from_server ? (*server_packet_count)++ : (*client_packet_count)++); - if (!(*print_line_fcn_p) (initbuf, strlen(initbuf), is_from_server, arg)) - return FRS_PRINT_ERROR; - - while (current_pos < nchars) { - gchar hexbuf[256]; - int i, cur; - - cur = 0; - for (i = 0; i < 8 && current_pos + i < nchars; i++) { - /* Prepend entries with "0x" */ - hexbuf[cur++] = '0'; - hexbuf[cur++] = 'x'; - hexbuf[cur++] = - hexchars[(buffer[current_pos + i] & 0xf0) >> 4]; - hexbuf[cur++] = - hexchars[buffer[current_pos + i] & 0x0f]; - - /* Delimit array entries with a comma */ - if (current_pos + i + 1 < nchars) - hexbuf[cur++] = ','; - - hexbuf[cur++] = ' '; - } - - /* Terminate the array if we are at the end */ - if (current_pos + i == nchars) { - hexbuf[cur++] = '}'; - hexbuf[cur++] = ';'; - } - - current_pos += i; - (*global_pos) += i; - hexbuf[cur++] = '\n'; - hexbuf[cur] = 0; - if (!(*print_line_fcn_p) (hexbuf, strlen(hexbuf), is_from_server, arg)) - return FRS_PRINT_ERROR; - } - break; - } - - return FRS_OK; + gchar initbuf[256]; + guint32 current_pos; + static const gchar hexchars[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; + + switch (follow_info->show_type) { + + case SHOW_EBCDIC: + /* If our native arch is ASCII, call: */ + EBCDIC_to_ASCII(buffer, (guint) nchars); + if (!(*print_line_fcn_p) (buffer, nchars, is_from_server, arg)) + return FRS_PRINT_ERROR; + break; + + case SHOW_ASCII: + /* If our native arch is EBCDIC, call: + * ASCII_TO_EBCDIC(buffer, nchars); + */ + if (!(*print_line_fcn_p) (buffer, nchars, is_from_server, arg)) + return FRS_PRINT_ERROR; + break; + + case SHOW_RAW: + /* Don't translate, no matter what the native arch + * is. + */ + if (!(*print_line_fcn_p) (buffer, nchars, is_from_server, arg)) + return FRS_PRINT_ERROR; + break; + + case SHOW_HEXDUMP: + current_pos = 0; + while (current_pos < nchars) { + gchar hexbuf[256]; + int i; + gchar *cur = hexbuf, *ascii_start; + + /* is_from_server indentation : put 4 spaces at the + * beginning of the string */ + /* XXX - We might want to prepend each line with "C" or "S" instead. */ + if (is_from_server && follow_info->show_stream == BOTH_HOSTS) { + memset(cur, ' ', 4); + cur += 4; + } + cur += g_snprintf(cur, 20, "%08X ", *global_pos); + /* 49 is space consumed by hex chars */ + ascii_start = cur + 49; + for (i = 0; i < 16 && current_pos + i < nchars; i++) { + *cur++ = + hexchars[(buffer[current_pos + i] & 0xf0) >> 4]; + *cur++ = + hexchars[buffer[current_pos + i] & 0x0f]; + *cur++ = ' '; + if (i == 7) + *cur++ = ' '; + } + /* Fill it up if column isn't complete */ + while (cur < ascii_start) + *cur++ = ' '; + + /* Now dump bytes as text */ + for (i = 0; i < 16 && current_pos + i < nchars; i++) { + *cur++ = + (isprint((guchar)buffer[current_pos + i]) ? + buffer[current_pos + i] : '.' ); + if (i == 7) { + *cur++ = ' '; + } + } + current_pos += i; + (*global_pos) += i; + *cur++ = '\n'; + *cur = 0; + if (!(*print_line_fcn_p) (hexbuf, strlen(hexbuf), is_from_server, arg)) + return FRS_PRINT_ERROR; + } + break; + + case SHOW_CARRAY: + current_pos = 0; + g_snprintf(initbuf, sizeof(initbuf), "char peer%d_%d[] = {\n", + is_from_server ? 1 : 0, + is_from_server ? (*server_packet_count)++ : (*client_packet_count)++); + if (!(*print_line_fcn_p) (initbuf, strlen(initbuf), is_from_server, arg)) + return FRS_PRINT_ERROR; + + while (current_pos < nchars) { + gchar hexbuf[256]; + int i, cur; + + cur = 0; + for (i = 0; i < 8 && current_pos + i < nchars; i++) { + /* Prepend entries with "0x" */ + hexbuf[cur++] = '0'; + hexbuf[cur++] = 'x'; + hexbuf[cur++] = hexchars[(buffer[current_pos + i] & 0xf0) >> 4]; + hexbuf[cur++] = hexchars[buffer[current_pos + i] & 0x0f]; + + /* Delimit array entries with a comma */ + if (current_pos + i + 1 < nchars) + hexbuf[cur++] = ','; + + hexbuf[cur++] = ' '; + } + + /* Terminate the array if we are at the end */ + if (current_pos + i == nchars) { + hexbuf[cur++] = '}'; + hexbuf[cur++] = ';'; + } + + current_pos += i; + (*global_pos) += i; + hexbuf[cur++] = '\n'; + hexbuf[cur] = 0; + if (!(*print_line_fcn_p) (hexbuf, strlen(hexbuf), is_from_server, arg)) + return FRS_PRINT_ERROR; + } + break; + } + + return FRS_OK; } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/gtk/follow_stream.h b/ui/gtk/follow_stream.h index beba0d0219..c55abf8abc 100644 --- a/ui/gtk/follow_stream.h +++ b/ui/gtk/follow_stream.h @@ -30,59 +30,59 @@ /* Type of follow we are doing */ typedef enum { - FOLLOW_TCP, - FOLLOW_SSL, - FOLLOW_UDP + FOLLOW_TCP, + FOLLOW_SSL, + FOLLOW_UDP } follow_type_t; /* Show Stream */ typedef enum { - FROM_CLIENT, - FROM_SERVER, - BOTH_HOSTS + FROM_CLIENT, + FROM_SERVER, + BOTH_HOSTS } show_stream_t; /* Show Type */ typedef enum { - SHOW_ASCII, - SHOW_EBCDIC, - SHOW_HEXDUMP, - SHOW_CARRAY, - SHOW_RAW + SHOW_ASCII, + SHOW_EBCDIC, + SHOW_HEXDUMP, + SHOW_CARRAY, + SHOW_RAW } show_type_t; typedef enum { - FRS_OK, - FRS_OPEN_ERROR, - FRS_READ_ERROR, - FRS_PRINT_ERROR + FRS_OK, + FRS_OPEN_ERROR, + FRS_READ_ERROR, + FRS_PRINT_ERROR } frs_return_t; typedef struct { - gboolean is_server; - GByteArray *data; + gboolean is_server; + GByteArray *data; } follow_record_t; typedef struct { - follow_type_t follow_type; - show_stream_t show_stream; - show_type_t show_type; - char *data_out_filename; - GtkWidget *text; - GtkWidget *ascii_bt; - GtkWidget *ebcdic_bt; - GtkWidget *hexdump_bt; - GtkWidget *carray_bt; - GtkWidget *raw_bt; - GtkWidget *find_dlg_w; - gboolean is_ipv6; - char *filter_out_filter; - GtkWidget *filter_te; - GtkWidget *streamwindow; - GList *payload; - guint bytes_written[2]; /* Index with FROM_CLIENT or FROM_SERVER for readability. */ - guint client_port; - address client_ip; + follow_type_t follow_type; + show_stream_t show_stream; + show_type_t show_type; + char *data_out_filename; + GtkWidget *text; + GtkWidget *ascii_bt; + GtkWidget *ebcdic_bt; + GtkWidget *hexdump_bt; + GtkWidget *carray_bt; + GtkWidget *raw_bt; + GtkWidget *find_dlg_w; + gboolean is_ipv6; + char *filter_out_filter; + GtkWidget *filter_te; + GtkWidget *streamwindow; + GList *payload; + guint bytes_written[2]; /* Index with FROM_CLIENT or FROM_SERVER for readability. */ + guint client_port; + address client_ip; } follow_info_t; #define E_FOLLOW_INFO_KEY "follow_info_key" @@ -94,21 +94,33 @@ extern GList *follow_infos; void follow_load_text(follow_info_t *follow_info); void follow_filter_out_stream(GtkWidget * w, gpointer parent_w); void follow_stream(const gchar *title, follow_info_t *follow_info, - gchar *both_directions_string, - gchar *server_to_client_string, - gchar *client_to_server_string); + gchar *both_directions_string, + gchar *server_to_client_string, + gchar *client_to_server_string); frs_return_t follow_show(follow_info_t *follow_info, - gboolean (*print_line)(char *, size_t, gboolean, - void *), - char *buffer, size_t nchars, gboolean is_server, - void *arg, guint32 *global_pos, - guint32 *server_packet_count, - guint32 *client_packet_count); + gboolean (*print_line)(char *, size_t, gboolean, void *), + char *buffer, size_t nchars, gboolean is_server, + void *arg, guint32 *global_pos, + guint32 *server_packet_count, + guint32 *client_packet_count); gboolean follow_add_to_gtk_text(char *buffer, size_t nchars, gboolean is_server, - void *arg); + void *arg); frs_return_t follow_read_tcp_stream(follow_info_t *follow_info, gboolean (*print_line)(char *, size_t, gboolean, void *), void *arg); frs_return_t follow_read_udp_stream(follow_info_t *follow_info, gboolean (*print_line)(char *, size_t, gboolean, void *), void *arg); frs_return_t follow_read_ssl_stream(follow_info_t *follow_info, gboolean (*print_line)(char *, size_t, gboolean, void *), void *arg); #endif /* __FOLLOW_STREAM_H__ */ + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/gtk/follow_tcp.c b/ui/gtk/follow_tcp.c index 1ad1cc8bce..c188e0134c 100644 --- a/ui/gtk/follow_tcp.c +++ b/ui/gtk/follow_tcp.c @@ -77,14 +77,14 @@ WS_DLL_PUBLIC FILE *data_out_file; static void follow_redraw(gpointer data, gpointer user_data _U_) { - follow_load_text((follow_info_t *)data); + follow_load_text((follow_info_t *)data); } /* Redraw the text in all "Follow TCP Stream" windows. */ void follow_tcp_redraw_all(void) { - g_list_foreach(follow_infos, follow_redraw, NULL); + g_list_foreach(follow_infos, follow_redraw, NULL); } /* Follow the TCP stream, if any, to which the last packet that we called @@ -93,227 +93,227 @@ follow_tcp_redraw_all(void) void follow_tcp_stream_cb(GtkWidget * w _U_, gpointer data _U_) { - GtkWidget *filter_cm; - GtkWidget *filter_te; - int tmp_fd; - gchar *follow_filter; - const gchar *previous_filter; - int filter_out_filter_len; - const char *hostname0, *hostname1; - char *port0, *port1; - gchar *server_to_client_string = NULL; - gchar *client_to_server_string = NULL; - gchar *both_directions_string = NULL; - follow_stats_t stats; - follow_info_t *follow_info; - tcp_stream_chunk sc; - size_t nchars; - gchar *data_out_filename; - char stream_window_title[256]; - - /* we got tcp so we can follow */ - if (cfile.edt->pi.ipproto != IP_PROTO_TCP) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Error following stream. Please make\n" - "sure you have a TCP packet selected."); - return; - } - - follow_info = g_new0(follow_info_t, 1); - follow_info->follow_type = FOLLOW_TCP; - - /* Create a new filter that matches all packets in the TCP stream, - and set the display filter entry accordingly */ - reset_tcp_reassembly(); - follow_filter = build_follow_filter(&cfile.edt->pi); - if (!follow_filter) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Error creating filter for this stream.\n" - "A transport or network layer header is needed"); - g_free(follow_info); - return; - } - - /* Create a temporary file into which to dump the reassembled data - from the TCP stream, and set "data_out_file" to refer to it, so - that the TCP code will write to it. - - XXX - it might be nicer to just have the TCP code directly - append stuff to the text widget for the TCP stream window, - if we can arrange that said window not pop up until we're - done. */ - tmp_fd = create_tempfile(&data_out_filename, "follow"); - follow_info->data_out_filename = g_strdup(data_out_filename); - - if (tmp_fd == -1) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Could not create temporary file %s: %s", - follow_info->data_out_filename, g_strerror(errno)); - g_free(follow_info->data_out_filename); - g_free(follow_info); - g_free(follow_filter); - return; - } - - data_out_file = fdopen(tmp_fd, "w+b"); - if (data_out_file == NULL) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Could not create temporary file %s: %s", - follow_info->data_out_filename, g_strerror(errno)); - ws_close(tmp_fd); - ws_unlink(follow_info->data_out_filename); - g_free(follow_info->data_out_filename); - g_free(follow_info); - g_free(follow_filter); - return; - } - - /* Set the display filter entry accordingly */ - filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY); - filter_te = gtk_bin_get_child(GTK_BIN(filter_cm)); - - /* needed in follow_filter_out_stream(), is there a better way? */ - follow_info->filter_te = filter_te; - - /* save previous filter, const since we're not supposed to alter */ - previous_filter = - (const gchar *)gtk_entry_get_text(GTK_ENTRY(filter_te)); - - /* allocate our new filter. API claims g_malloc terminates program on failure */ - /* my calc for max alloc needed is really +10 but when did a few extra bytes hurt ? */ - filter_out_filter_len = (int)(strlen(follow_filter) + strlen(previous_filter) + 16); - follow_info->filter_out_filter = (gchar *)g_malloc(filter_out_filter_len); - - /* append the negation */ - if(strlen(previous_filter)) { - g_snprintf(follow_info->filter_out_filter, filter_out_filter_len, + GtkWidget *filter_cm; + GtkWidget *filter_te; + int tmp_fd; + gchar *follow_filter; + const gchar *previous_filter; + int filter_out_filter_len; + const char *hostname0, *hostname1; + char *port0, *port1; + gchar *server_to_client_string = NULL; + gchar *client_to_server_string = NULL; + gchar *both_directions_string = NULL; + follow_stats_t stats; + follow_info_t *follow_info; + tcp_stream_chunk sc; + size_t nchars; + gchar *data_out_filename; + char stream_window_title[256]; + + /* we got tcp so we can follow */ + if (cfile.edt->pi.ipproto != IP_PROTO_TCP) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Error following stream. Please make\n" + "sure you have a TCP packet selected."); + return; + } + + follow_info = g_new0(follow_info_t, 1); + follow_info->follow_type = FOLLOW_TCP; + + /* Create a new filter that matches all packets in the TCP stream, + and set the display filter entry accordingly */ + reset_tcp_reassembly(); + follow_filter = build_follow_filter(&cfile.edt->pi); + if (!follow_filter) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Error creating filter for this stream.\n" + "A transport or network layer header is needed"); + g_free(follow_info); + return; + } + + /* Create a temporary file into which to dump the reassembled data + from the TCP stream, and set "data_out_file" to refer to it, so + that the TCP code will write to it. + + XXX - it might be nicer to just have the TCP code directly + append stuff to the text widget for the TCP stream window, + if we can arrange that said window not pop up until we're + done. */ + tmp_fd = create_tempfile(&data_out_filename, "follow"); + follow_info->data_out_filename = g_strdup(data_out_filename); + + if (tmp_fd == -1) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Could not create temporary file %s: %s", + follow_info->data_out_filename, g_strerror(errno)); + g_free(follow_info->data_out_filename); + g_free(follow_info); + g_free(follow_filter); + return; + } + + data_out_file = fdopen(tmp_fd, "w+b"); + if (data_out_file == NULL) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Could not create temporary file %s: %s", + follow_info->data_out_filename, g_strerror(errno)); + ws_close(tmp_fd); + ws_unlink(follow_info->data_out_filename); + g_free(follow_info->data_out_filename); + g_free(follow_info); + g_free(follow_filter); + return; + } + + /* Set the display filter entry accordingly */ + filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY); + filter_te = gtk_bin_get_child(GTK_BIN(filter_cm)); + + /* needed in follow_filter_out_stream(), is there a better way? */ + follow_info->filter_te = filter_te; + + /* save previous filter, const since we're not supposed to alter */ + previous_filter = + (const gchar *)gtk_entry_get_text(GTK_ENTRY(filter_te)); + + /* allocate our new filter. API claims g_malloc terminates program on failure */ + /* my calc for max alloc needed is really +10 but when did a few extra bytes hurt ? */ + filter_out_filter_len = (int)(strlen(follow_filter) + strlen(previous_filter) + 16); + follow_info->filter_out_filter = (gchar *)g_malloc(filter_out_filter_len); + + /* append the negation */ + if(strlen(previous_filter)) { + g_snprintf(follow_info->filter_out_filter, filter_out_filter_len, "%s and !(%s)", previous_filter, follow_filter); - } else { - g_snprintf(follow_info->filter_out_filter, filter_out_filter_len, + } else { + g_snprintf(follow_info->filter_out_filter, filter_out_filter_len, "!(%s)", follow_filter); - } - - gtk_entry_set_text(GTK_ENTRY(filter_te), follow_filter); - - /* Run the display filter so it goes in effect - even if it's the - same as the previous display filter. */ - main_filter_packets(&cfile, follow_filter, TRUE); - - /* Check whether we got any data written to the file. */ - if (empty_tcp_stream) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "The packets in the capture file for that stream have no data."); - ws_close(tmp_fd); - ws_unlink(follow_info->data_out_filename); - g_free(follow_info->data_out_filename); - g_free(follow_info->filter_out_filter); - g_free(follow_info); - return; - } - - /* Go back to the top of the file and read the first tcp_stream_chunk - * to ensure that the IP addresses and port numbers in the drop-down - * list are tied to the correct lines displayed by follow_read_stream() - * later on (which also reads from this file). Close the file when - * we're done. - * - * We read the data now, before we pop up a window, in case the - * read fails. We use the data later. - */ - - rewind(data_out_file); - nchars=fread(&sc, 1, sizeof(sc), data_out_file); - if (nchars != sizeof(sc)) { - if (ferror(data_out_file)) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Could not read from temporary file %s: %s", - follow_info->data_out_filename, g_strerror(errno)); - } else { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Short read from temporary file %s: expected %lu, got %lu", - follow_info->data_out_filename, - (unsigned long)sizeof(sc), - (unsigned long)nchars); - } - ws_close(tmp_fd); - ws_unlink(follow_info->data_out_filename); - g_free(follow_info->data_out_filename); - g_free(follow_info->filter_out_filter); - g_free(follow_info); - return; - } - fclose(data_out_file); - - /* The data_out_filename file now has all the text that was in the - session (this is dumped to file by the TCP dissector). */ - - /* Stream to show */ - follow_stats(&stats); - - if (stats.is_ipv6) { - struct e_in6_addr ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 16); - hostname0 = get_hostname6(&ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 16); - hostname1 = get_hostname6(&ipaddr); - } else { - guint32 ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 4); - hostname0 = get_hostname(ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 4); - hostname1 = get_hostname(ipaddr); - } - - follow_info->is_ipv6 = stats.is_ipv6; - - port0 = get_tcp_port(stats.port[0]); - port1 = get_tcp_port(stats.port[1]); - - /* Host 0 --> Host 1 */ - if(sc.src_port == stats.port[0]) { - server_to_client_string = - g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", - hostname0, port0, - hostname1, port1, - stats.bytes_written[0]); - } else { - server_to_client_string = - g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", - hostname1, port1, - hostname0,port0, - stats.bytes_written[0]); - } - - /* Host 1 --> Host 0 */ - if(sc.src_port == stats.port[1]) { - client_to_server_string = - g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", - hostname0, port0, - hostname1, port1, - stats.bytes_written[1]); - } else { - client_to_server_string = - g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", - hostname1, port1, - hostname0, port0, - stats.bytes_written[1]); - } - - /* Both Stream Directions */ - both_directions_string = g_strdup_printf("Entire conversation (%u bytes)", stats.bytes_written[0] + stats.bytes_written[1]); - - g_snprintf(stream_window_title, 256, "Follow TCP Stream (%s)", follow_filter); - follow_stream(stream_window_title, follow_info, both_directions_string, - server_to_client_string, client_to_server_string); - - /* Free the filter string, as we're done with it. */ - g_free(follow_filter); - - g_free(both_directions_string); - g_free(server_to_client_string); - g_free(client_to_server_string); - - data_out_file = NULL; + } + + gtk_entry_set_text(GTK_ENTRY(filter_te), follow_filter); + + /* Run the display filter so it goes in effect - even if it's the + same as the previous display filter. */ + main_filter_packets(&cfile, follow_filter, TRUE); + + /* Check whether we got any data written to the file. */ + if (empty_tcp_stream) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "The packets in the capture file for that stream have no data."); + ws_close(tmp_fd); + ws_unlink(follow_info->data_out_filename); + g_free(follow_info->data_out_filename); + g_free(follow_info->filter_out_filter); + g_free(follow_info); + return; + } + + /* Go back to the top of the file and read the first tcp_stream_chunk + * to ensure that the IP addresses and port numbers in the drop-down + * list are tied to the correct lines displayed by follow_read_stream() + * later on (which also reads from this file). Close the file when + * we're done. + * + * We read the data now, before we pop up a window, in case the + * read fails. We use the data later. + */ + + rewind(data_out_file); + nchars=fread(&sc, 1, sizeof(sc), data_out_file); + if (nchars != sizeof(sc)) { + if (ferror(data_out_file)) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Could not read from temporary file %s: %s", + follow_info->data_out_filename, g_strerror(errno)); + } else { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Short read from temporary file %s: expected %lu, got %lu", + follow_info->data_out_filename, + (unsigned long)sizeof(sc), + (unsigned long)nchars); + } + ws_close(tmp_fd); + ws_unlink(follow_info->data_out_filename); + g_free(follow_info->data_out_filename); + g_free(follow_info->filter_out_filter); + g_free(follow_info); + return; + } + fclose(data_out_file); + + /* The data_out_filename file now has all the text that was in the + session (this is dumped to file by the TCP dissector). */ + + /* Stream to show */ + follow_stats(&stats); + + if (stats.is_ipv6) { + struct e_in6_addr ipaddr; + memcpy(&ipaddr, stats.ip_address[0], 16); + hostname0 = get_hostname6(&ipaddr); + memcpy(&ipaddr, stats.ip_address[1], 16); + hostname1 = get_hostname6(&ipaddr); + } else { + guint32 ipaddr; + memcpy(&ipaddr, stats.ip_address[0], 4); + hostname0 = get_hostname(ipaddr); + memcpy(&ipaddr, stats.ip_address[1], 4); + hostname1 = get_hostname(ipaddr); + } + + follow_info->is_ipv6 = stats.is_ipv6; + + port0 = get_tcp_port(stats.port[0]); + port1 = get_tcp_port(stats.port[1]); + + /* Host 0 --> Host 1 */ + if(sc.src_port == stats.port[0]) { + server_to_client_string = + g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", + hostname0, port0, + hostname1, port1, + stats.bytes_written[0]); + } else { + server_to_client_string = + g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", + hostname1, port1, + hostname0,port0, + stats.bytes_written[0]); + } + + /* Host 1 --> Host 0 */ + if(sc.src_port == stats.port[1]) { + client_to_server_string = + g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", + hostname0, port0, + hostname1, port1, + stats.bytes_written[1]); + } else { + client_to_server_string = + g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", + hostname1, port1, + hostname0, port0, + stats.bytes_written[1]); + } + + /* Both Stream Directions */ + both_directions_string = g_strdup_printf("Entire conversation (%u bytes)", stats.bytes_written[0] + stats.bytes_written[1]); + + g_snprintf(stream_window_title, 256, "Follow TCP Stream (%s)", follow_filter); + follow_stream(stream_window_title, follow_info, both_directions_string, + server_to_client_string, client_to_server_string); + + /* Free the filter string, as we're done with it. */ + g_free(follow_filter); + + g_free(both_directions_string); + g_free(server_to_client_string); + g_free(client_to_server_string); + + data_out_file = NULL; } #ifdef HAVE_LIBZ @@ -415,179 +415,192 @@ parse_http_header(char *data, size_t len, size_t *content_start) */ frs_return_t follow_read_tcp_stream(follow_info_t *follow_info, - gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), - void *arg) + gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), + void *arg) { - tcp_stream_chunk sc; - size_t bcount; - size_t bytes_read; - int iplen; - guint8 client_addr[MAX_IPADDR_LEN]; - guint16 client_port = 0; - gboolean is_server; - guint32 global_client_pos = 0, global_server_pos = 0; - guint32 server_packet_count = 0; - guint32 client_packet_count = 0; - guint32 *global_pos; - gboolean skip; - char buffer[FLT_BUF_SIZE+1]; /* +1 to fix ws bug 1043 */ - size_t nchars; - frs_return_t frs_return; + tcp_stream_chunk sc; + size_t bcount; + size_t bytes_read; + int iplen; + guint8 client_addr[MAX_IPADDR_LEN]; + guint16 client_port = 0; + gboolean is_server; + guint32 global_client_pos = 0, global_server_pos = 0; + guint32 server_packet_count = 0; + guint32 client_packet_count = 0; + guint32 *global_pos; + gboolean skip; + char buffer[FLT_BUF_SIZE+1]; /* +1 to fix ws bug 1043 */ + size_t nchars; + frs_return_t frs_return; #ifdef HAVE_LIBZ - char outbuffer[FLT_BUF_SIZE+1]; - z_stream strm; - gboolean gunzip = FALSE; - int ret; + char outbuffer[FLT_BUF_SIZE+1]; + z_stream strm; + gboolean gunzip = FALSE; + int ret; #endif - iplen = (follow_info->is_ipv6) ? 16 : 4; - - data_out_file = ws_fopen(follow_info->data_out_filename, "rb"); - if (data_out_file == NULL) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Could not open temporary file %s: %s", follow_info->data_out_filename, - g_strerror(errno)); - return FRS_OPEN_ERROR; - } - - while ((nchars=fread(&sc, 1, sizeof(sc), data_out_file))) { - if (nchars != sizeof(sc)) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Short read from temporary file %s: expected %lu, got %lu", - follow_info->data_out_filename, - (unsigned long)sizeof(sc), - (unsigned long)nchars); - fclose(data_out_file); - data_out_file = NULL; - return FRS_READ_ERROR; - } - if (client_port == 0) { - memcpy(client_addr, sc.src_addr, iplen); - client_port = sc.src_port; - } - skip = FALSE; - if (memcmp(client_addr, sc.src_addr, iplen) == 0 && - client_port == sc.src_port) { - is_server = FALSE; - global_pos = &global_client_pos; - if (follow_info->show_stream == FROM_SERVER) { - skip = TRUE; - } - } - else { - is_server = TRUE; - global_pos = &global_server_pos; - if (follow_info->show_stream == FROM_CLIENT) { - skip = TRUE; - } - } - - bytes_read = 0; - while (bytes_read < sc.dlen) { - bcount = ((sc.dlen-bytes_read) < FLT_BUF_SIZE) ? (sc.dlen-bytes_read) : FLT_BUF_SIZE; - nchars = fread(buffer, 1, bcount, data_out_file); - if (nchars == 0) - break; - /* XXX - if we don't get "bcount" bytes, is that an error? */ - bytes_read += nchars; + iplen = (follow_info->is_ipv6) ? 16 : 4; + + data_out_file = ws_fopen(follow_info->data_out_filename, "rb"); + if (data_out_file == NULL) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Could not open temporary file %s: %s", follow_info->data_out_filename, + g_strerror(errno)); + return FRS_OPEN_ERROR; + } + + while ((nchars=fread(&sc, 1, sizeof(sc), data_out_file))) { + if (nchars != sizeof(sc)) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Short read from temporary file %s: expected %lu, got %lu", + follow_info->data_out_filename, + (unsigned long)sizeof(sc), + (unsigned long)nchars); + fclose(data_out_file); + data_out_file = NULL; + return FRS_READ_ERROR; + } + if (client_port == 0) { + memcpy(client_addr, sc.src_addr, iplen); + client_port = sc.src_port; + } + skip = FALSE; + if (memcmp(client_addr, sc.src_addr, iplen) == 0 && + client_port == sc.src_port) { + is_server = FALSE; + global_pos = &global_client_pos; + if (follow_info->show_stream == FROM_SERVER) { + skip = TRUE; + } + } + else { + is_server = TRUE; + global_pos = &global_server_pos; + if (follow_info->show_stream == FROM_CLIENT) { + skip = TRUE; + } + } + + bytes_read = 0; + while (bytes_read < sc.dlen) { + bcount = ((sc.dlen-bytes_read) < FLT_BUF_SIZE) ? (sc.dlen-bytes_read) : FLT_BUF_SIZE; + nchars = fread(buffer, 1, bcount, data_out_file); + if (nchars == 0) + break; + /* XXX - if we don't get "bcount" bytes, is that an error? */ + bytes_read += nchars; #ifdef HAVE_LIBZ - /* If we are on the first packet of an HTTP response, check if data is gzip - * compressed. - */ - if (is_server && bytes_read == nchars && !memcmp(buffer, "HTTP", 4)) { - size_t header_len; - gunzip = parse_http_header(buffer, nchars, &header_len); - if (gunzip) { - /* show header (which is not gzipped)*/ - frs_return = follow_show(follow_info, print_line_fcn_p, buffer, - header_len, is_server, arg, global_pos, - &server_packet_count, &client_packet_count); - if (frs_return == FRS_PRINT_ERROR) { - fclose(data_out_file); - data_out_file = NULL; - return frs_return; - } - - /* init gz_stream*/ - strm.next_in = Z_NULL; - strm.avail_in = 0; - strm.next_out = Z_NULL; - strm.avail_out = 0; - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - ret = inflateInit2(&strm, MAX_WBITS+16); - if (ret != Z_OK) { - fclose(data_out_file); - data_out_file = NULL; - return FRS_READ_ERROR; - } - - /* prepare remainder of buffer to be inflated below */ - memmove(buffer, buffer+header_len, nchars-header_len); - nchars -= header_len; - } - } - - if (gunzip) { - strm.next_in = buffer; - strm.avail_in = (int)nchars; - do { - strm.next_out = outbuffer; - strm.avail_out = FLT_BUF_SIZE; - - ret = inflate(&strm, Z_NO_FLUSH); - if (ret < 0 || ret == Z_NEED_DICT) { - inflateEnd(&strm); - fclose(data_out_file); - data_out_file = NULL; - return FRS_READ_ERROR; - } else if (ret == Z_STREAM_END) { - inflateEnd(&strm); - } - - frs_return = follow_show(follow_info, print_line_fcn_p, outbuffer, - FLT_BUF_SIZE-strm.avail_out, is_server, - arg, global_pos, - &server_packet_count, - &client_packet_count); - if(frs_return == FRS_PRINT_ERROR) { - inflateEnd(&strm); - fclose(data_out_file); - data_out_file = NULL; - return frs_return; - } - } while (strm.avail_out == 0); - skip = TRUE; - } + /* If we are on the first packet of an HTTP response, check if data is gzip + * compressed. + */ + if (is_server && bytes_read == nchars && !memcmp(buffer, "HTTP", 4)) { + size_t header_len; + gunzip = parse_http_header(buffer, nchars, &header_len); + if (gunzip) { + /* show header (which is not gzipped)*/ + frs_return = follow_show(follow_info, print_line_fcn_p, buffer, + header_len, is_server, arg, global_pos, + &server_packet_count, &client_packet_count); + if (frs_return == FRS_PRINT_ERROR) { + fclose(data_out_file); + data_out_file = NULL; + return frs_return; + } + + /* init gz_stream*/ + strm.next_in = Z_NULL; + strm.avail_in = 0; + strm.next_out = Z_NULL; + strm.avail_out = 0; + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + ret = inflateInit2(&strm, MAX_WBITS+16); + if (ret != Z_OK) { + fclose(data_out_file); + data_out_file = NULL; + return FRS_READ_ERROR; + } + + /* prepare remainder of buffer to be inflated below */ + memmove(buffer, buffer+header_len, nchars-header_len); + nchars -= header_len; + } + } + + if (gunzip) { + strm.next_in = buffer; + strm.avail_in = (int)nchars; + do { + strm.next_out = outbuffer; + strm.avail_out = FLT_BUF_SIZE; + + ret = inflate(&strm, Z_NO_FLUSH); + if (ret < 0 || ret == Z_NEED_DICT) { + inflateEnd(&strm); + fclose(data_out_file); + data_out_file = NULL; + return FRS_READ_ERROR; + } else if (ret == Z_STREAM_END) { + inflateEnd(&strm); + } + + frs_return = follow_show(follow_info, print_line_fcn_p, outbuffer, + FLT_BUF_SIZE-strm.avail_out, is_server, + arg, global_pos, + &server_packet_count, + &client_packet_count); + if(frs_return == FRS_PRINT_ERROR) { + inflateEnd(&strm); + fclose(data_out_file); + data_out_file = NULL; + return frs_return; + } + } while (strm.avail_out == 0); + skip = TRUE; + } #endif - if (!skip) { - frs_return = follow_show(follow_info, print_line_fcn_p, buffer, - nchars, is_server, arg, global_pos, - &server_packet_count, - &client_packet_count); - if(frs_return == FRS_PRINT_ERROR) { - fclose(data_out_file); - data_out_file = NULL; - return frs_return; - - } - } - } - } - - if (ferror(data_out_file)) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Error reading temporary file %s: %s", follow_info->data_out_filename, - g_strerror(errno)); - fclose(data_out_file); - data_out_file = NULL; - return FRS_READ_ERROR; - } - - fclose(data_out_file); - data_out_file = NULL; - return FRS_OK; + if (!skip) { + frs_return = follow_show(follow_info, print_line_fcn_p, buffer, + nchars, is_server, arg, global_pos, + &server_packet_count, + &client_packet_count); + if(frs_return == FRS_PRINT_ERROR) { + fclose(data_out_file); + data_out_file = NULL; + return frs_return; + + } + } + } + } + + if (ferror(data_out_file)) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Error reading temporary file %s: %s", follow_info->data_out_filename, + g_strerror(errno)); + fclose(data_out_file); + data_out_file = NULL; + return FRS_READ_ERROR; + } + + fclose(data_out_file); + data_out_file = NULL; + return FRS_OK; } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/gtk/follow_tcp.h b/ui/gtk/follow_tcp.h index 105d1342ad..7d2f0a0c78 100644 --- a/ui/gtk/follow_tcp.h +++ b/ui/gtk/follow_tcp.h @@ -42,3 +42,16 @@ extern void follow_tcp_stream_cb( GtkWidget *widget, gpointer data); extern void follow_tcp_redraw_all(void); #endif /* __FOLLOW_TCP_H__ */ + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/gtk/follow_udp.c b/ui/gtk/follow_udp.c index 59d7b6ba81..37061de568 100644 --- a/ui/gtk/follow_udp.c +++ b/ui/gtk/follow_udp.c @@ -46,37 +46,34 @@ static int udp_queue_packet_data(void *tapdata, packet_info *pinfo, - epan_dissect_t *edt _U_, const void *data) + epan_dissect_t *edt _U_, const void *data) { - follow_record_t *follow_record; - follow_info_t *follow_info = (follow_info_t *)tapdata; - tvbuff_t *next_tvb = (tvbuff_t *)data; - - follow_record = g_new(follow_record_t,1); - - follow_record->data = g_byte_array_sized_new(tvb_length(next_tvb)); - follow_record->data = g_byte_array_append(follow_record->data, - tvb_get_ptr(next_tvb, 0, -1), - tvb_length(next_tvb)); - - if (follow_info->client_port == 0) { - follow_info->client_port = pinfo->srcport; - COPY_ADDRESS(&follow_info->client_ip, &pinfo->src); - } - - if (ADDRESSES_EQUAL(&follow_info->client_ip, &pinfo->src) && - follow_info->client_port == pinfo->srcport) - follow_record->is_server = FALSE; - else - follow_record->is_server = TRUE; - - /* update stream counter */ - follow_info->bytes_written[follow_record->is_server] += - follow_record->data->len; - - follow_info->payload = g_list_append(follow_info->payload, - follow_record); - return 0; + follow_record_t *follow_record; + follow_info_t *follow_info = (follow_info_t *)tapdata; + tvbuff_t *next_tvb = (tvbuff_t *)data; + + follow_record = g_new(follow_record_t,1); + + follow_record->data = g_byte_array_sized_new(tvb_length(next_tvb)); + follow_record->data = g_byte_array_append(follow_record->data, + tvb_get_ptr(next_tvb, 0, -1), + tvb_length(next_tvb)); + + if (follow_info->client_port == 0) { + follow_info->client_port = pinfo->srcport; + COPY_ADDRESS(&follow_info->client_ip, &pinfo->src); + } + + if (ADDRESSES_EQUAL(&follow_info->client_ip, &pinfo->src) && follow_info->client_port == pinfo->srcport) + follow_record->is_server = FALSE; + else + follow_record->is_server = TRUE; + + /* update stream counter */ + follow_info->bytes_written[follow_record->is_server] += follow_record->data->len; + + follow_info->payload = g_list_append(follow_info->payload, follow_record); + return 0; } @@ -86,149 +83,149 @@ udp_queue_packet_data(void *tapdata, packet_info *pinfo, void follow_udp_stream_cb(GtkWidget *w _U_, gpointer data _U_) { - GtkWidget *filter_te, *filter_cm; - gchar *follow_filter; - const gchar *previous_filter; - int filter_out_filter_len, previous_filter_len; - const char *hostname0, *hostname1; - char *port0, *port1; - gchar *server_to_client_string = NULL; - gchar *client_to_server_string = NULL; - gchar *both_directions_string = NULL; - follow_stats_t stats; - follow_info_t *follow_info; - GString *msg; - - /* we got udp so we can follow */ - if(cfile.edt->pi.ipproto != IP_PROTO_UDP) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Error following stream. Please make\n" - "sure you have a UDP packet selected."); - return; - } - - follow_info = g_new0(follow_info_t, 1); - follow_info->follow_type = FOLLOW_UDP; - - /* Create a new filter that matches all packets in the UDP stream, - and set the display filter entry accordingly */ - follow_filter = build_follow_filter(&cfile.edt->pi); - if (!follow_filter) - { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Error creating filter for this stream.\n" - "A network layer header is needed"); - g_free(follow_info); - return; - } - - /* Set the display filter entry accordingly */ - filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY); - filter_te = gtk_bin_get_child(GTK_BIN(filter_cm)); - - /* needed in follow_filter_out_stream(), is there a better way? */ - follow_info->filter_te = filter_te; - - /* save previous filter, const since we're not supposed to alter */ - previous_filter = - (const gchar *)gtk_entry_get_text(GTK_ENTRY(filter_te)); - - /* allocate our new filter. API claims g_malloc terminates program on failure */ - /* my calc for max alloc needed is really +10 but when did a few extra bytes hurt ? */ - previous_filter_len = previous_filter?(int)strlen(previous_filter):0; - filter_out_filter_len = (int)strlen(follow_filter) + previous_filter_len + 16; - follow_info->filter_out_filter = (gchar *)g_malloc(filter_out_filter_len); - - /* append the negation */ - if(previous_filter_len) { - g_snprintf(follow_info->filter_out_filter, filter_out_filter_len, - "%s and !(%s)", previous_filter, follow_filter); - } else { - g_snprintf(follow_info->filter_out_filter, filter_out_filter_len, - "!(%s)", follow_filter); - } - - /* data will be passed via tap callback*/ - msg = register_tap_listener("udp_follow", follow_info, follow_filter, - 0, NULL, udp_queue_packet_data, NULL); - if (msg) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Can't register udp_follow tap: %s\n", - msg->str); - g_free(follow_info->filter_out_filter); - g_free(follow_info); - g_free(follow_filter); - return; - } - - gtk_entry_set_text(GTK_ENTRY(filter_te), follow_filter); - - /* Run the display filter so it goes in effect - even if it's the - same as the previous display filter. */ - main_filter_packets(&cfile, follow_filter, TRUE); - - /* Free the filter string, as we're done with it. */ - g_free(follow_filter); - - remove_tap_listener(follow_info); - - /* Stream to show */ - follow_stats(&stats); - - if (stats.is_ipv6) { - struct e_in6_addr ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 16); - hostname0 = get_hostname6(&ipaddr); - memcpy(&ipaddr, stats.ip_address[0], 16); - hostname1 = get_hostname6(&ipaddr); - } else { - guint32 ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 4); - hostname0 = get_hostname(ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 4); - hostname1 = get_hostname(ipaddr); - } - - port0 = get_udp_port(stats.port[0]); - port1 = get_udp_port(stats.port[1]); - - follow_info->is_ipv6 = stats.is_ipv6; - - /* Both Stream Directions */ - both_directions_string = g_strdup_printf("Entire conversation (%u bytes)", follow_info->bytes_written[0] + follow_info->bytes_written[1]); - - if(follow_info->client_port == stats.port[0]) { - server_to_client_string = - g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", - hostname0, port0, - hostname1, port1, - follow_info->bytes_written[0]); - - client_to_server_string = - g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", - hostname1, port1, - hostname0, port0, - follow_info->bytes_written[1]); - } else { - server_to_client_string = - g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", - hostname1, port1, - hostname0, port0, - follow_info->bytes_written[0]); - - client_to_server_string = - g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", - hostname0, port0, - hostname1, port1, - follow_info->bytes_written[1]); - } - - follow_stream("Follow UDP Stream", follow_info, both_directions_string, - server_to_client_string, client_to_server_string); - - g_free(both_directions_string); - g_free(server_to_client_string); - g_free(client_to_server_string); + GtkWidget *filter_te, *filter_cm; + gchar *follow_filter; + const gchar *previous_filter; + int filter_out_filter_len, previous_filter_len; + const char *hostname0, *hostname1; + char *port0, *port1; + gchar *server_to_client_string = NULL; + gchar *client_to_server_string = NULL; + gchar *both_directions_string = NULL; + follow_stats_t stats; + follow_info_t *follow_info; + GString *msg; + + /* we got udp so we can follow */ + if(cfile.edt->pi.ipproto != IP_PROTO_UDP) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Error following stream. Please make\n" + "sure you have a UDP packet selected."); + return; + } + + follow_info = g_new0(follow_info_t, 1); + follow_info->follow_type = FOLLOW_UDP; + + /* Create a new filter that matches all packets in the UDP stream, + and set the display filter entry accordingly */ + follow_filter = build_follow_filter(&cfile.edt->pi); + if (!follow_filter) + { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Error creating filter for this stream.\n" + "A network layer header is needed"); + g_free(follow_info); + return; + } + + /* Set the display filter entry accordingly */ + filter_cm = (GtkWidget *)g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY); + filter_te = gtk_bin_get_child(GTK_BIN(filter_cm)); + + /* needed in follow_filter_out_stream(), is there a better way? */ + follow_info->filter_te = filter_te; + + /* save previous filter, const since we're not supposed to alter */ + previous_filter = + (const gchar *)gtk_entry_get_text(GTK_ENTRY(filter_te)); + + /* allocate our new filter. API claims g_malloc terminates program on failure */ + /* my calc for max alloc needed is really +10 but when did a few extra bytes hurt ? */ + previous_filter_len = previous_filter?(int)strlen(previous_filter):0; + filter_out_filter_len = (int)strlen(follow_filter) + previous_filter_len + 16; + follow_info->filter_out_filter = (gchar *)g_malloc(filter_out_filter_len); + + /* append the negation */ + if(previous_filter_len) { + g_snprintf(follow_info->filter_out_filter, filter_out_filter_len, + "%s and !(%s)", previous_filter, follow_filter); + } else { + g_snprintf(follow_info->filter_out_filter, filter_out_filter_len, + "!(%s)", follow_filter); + } + + /* data will be passed via tap callback*/ + msg = register_tap_listener("udp_follow", follow_info, follow_filter, + 0, NULL, udp_queue_packet_data, NULL); + if (msg) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Can't register udp_follow tap: %s\n", + msg->str); + g_free(follow_info->filter_out_filter); + g_free(follow_info); + g_free(follow_filter); + return; + } + + gtk_entry_set_text(GTK_ENTRY(filter_te), follow_filter); + + /* Run the display filter so it goes in effect - even if it's the + same as the previous display filter. */ + main_filter_packets(&cfile, follow_filter, TRUE); + + /* Free the filter string, as we're done with it. */ + g_free(follow_filter); + + remove_tap_listener(follow_info); + + /* Stream to show */ + follow_stats(&stats); + + if (stats.is_ipv6) { + struct e_in6_addr ipaddr; + memcpy(&ipaddr, stats.ip_address[0], 16); + hostname0 = get_hostname6(&ipaddr); + memcpy(&ipaddr, stats.ip_address[0], 16); + hostname1 = get_hostname6(&ipaddr); + } else { + guint32 ipaddr; + memcpy(&ipaddr, stats.ip_address[0], 4); + hostname0 = get_hostname(ipaddr); + memcpy(&ipaddr, stats.ip_address[1], 4); + hostname1 = get_hostname(ipaddr); + } + + port0 = get_udp_port(stats.port[0]); + port1 = get_udp_port(stats.port[1]); + + follow_info->is_ipv6 = stats.is_ipv6; + + /* Both Stream Directions */ + both_directions_string = g_strdup_printf("Entire conversation (%u bytes)", follow_info->bytes_written[0] + follow_info->bytes_written[1]); + + if(follow_info->client_port == stats.port[0]) { + server_to_client_string = + g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", + hostname0, port0, + hostname1, port1, + follow_info->bytes_written[0]); + + client_to_server_string = + g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", + hostname1, port1, + hostname0, port0, + follow_info->bytes_written[1]); + } else { + server_to_client_string = + g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", + hostname1, port1, + hostname0, port0, + follow_info->bytes_written[0]); + + client_to_server_string = + g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", + hostname0, port0, + hostname1, port1, + follow_info->bytes_written[1]); + } + + follow_stream("Follow UDP Stream", follow_info, both_directions_string, + server_to_client_string, client_to_server_string); + + g_free(both_directions_string); + g_free(server_to_client_string); + g_free(client_to_server_string); } #define FLT_BUF_SIZE 1024 @@ -252,51 +249,64 @@ follow_udp_stream_cb(GtkWidget *w _U_, gpointer data _U_) */ frs_return_t follow_read_udp_stream(follow_info_t *follow_info, - gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), - void *arg) + gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *), + void *arg) { - guint32 global_client_pos = 0, global_server_pos = 0; - guint32 server_packet_count = 0; - guint32 client_packet_count = 0; - guint32 *global_pos; - gboolean skip; - GList* cur; - frs_return_t frs_return; - follow_record_t *follow_record; - char *buffer; - - - for (cur = follow_info->payload; cur; cur = g_list_next(cur)) { - follow_record = (follow_record_t *)cur->data; - skip = FALSE; - if (!follow_record->is_server) { - global_pos = &global_client_pos; - if(follow_info->show_stream == FROM_SERVER) { - skip = TRUE; - } - } else { - global_pos = &global_server_pos; - if (follow_info->show_stream == FROM_CLIENT) { - skip = TRUE; - } - } - - if (!skip) { - buffer = (char *)g_memdup(follow_record->data->data, - follow_record->data->len); - - frs_return = follow_show(follow_info, print_line_fcn_p, - buffer, - follow_record->data->len, - follow_record->is_server, arg, - global_pos, - &server_packet_count, - &client_packet_count); - g_free(buffer); - if(frs_return == FRS_PRINT_ERROR) - return frs_return; - } - } - - return FRS_OK; + guint32 global_client_pos = 0, global_server_pos = 0; + guint32 server_packet_count = 0; + guint32 client_packet_count = 0; + guint32 *global_pos; + gboolean skip; + GList* cur; + frs_return_t frs_return; + follow_record_t *follow_record; + char *buffer; + + + for (cur = follow_info->payload; cur; cur = g_list_next(cur)) { + follow_record = (follow_record_t *)cur->data; + skip = FALSE; + if (!follow_record->is_server) { + global_pos = &global_client_pos; + if(follow_info->show_stream == FROM_SERVER) { + skip = TRUE; + } + } else { + global_pos = &global_server_pos; + if (follow_info->show_stream == FROM_CLIENT) { + skip = TRUE; + } + } + + if (!skip) { + buffer = (char *)g_memdup(follow_record->data->data, + follow_record->data->len); + + frs_return = follow_show(follow_info, print_line_fcn_p, + buffer, + follow_record->data->len, + follow_record->is_server, arg, + global_pos, + &server_packet_count, + &client_packet_count); + g_free(buffer); + if(frs_return == FRS_PRINT_ERROR) + return frs_return; + } + } + + return FRS_OK; } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/gtk/follow_udp.h b/ui/gtk/follow_udp.h index c98dcb9b49..5b6351a570 100644 --- a/ui/gtk/follow_udp.h +++ b/ui/gtk/follow_udp.h @@ -32,3 +32,16 @@ void follow_udp_stream_cb(GtkWidget * w, gpointer data _U_); #endif /* __FOLLOW_UDP_H__ */ +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ + |