diff options
-rw-r--r-- | debian/libwireshark0.symbols | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-lbmc.c | 7 | ||||
-rw-r--r-- | epan/sequence_analysis.c | 289 | ||||
-rw-r--r-- | epan/sequence_analysis.h | 10 | ||||
-rw-r--r-- | ui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ui/Makefile.am | 2 | ||||
-rw-r--r-- | ui/gtk/flow_graph.c | 15 | ||||
-rw-r--r-- | ui/gtk/graph_analysis.c | 5 | ||||
-rw-r--r-- | ui/gtk/graph_analysis.h | 2 | ||||
-rw-r--r-- | ui/qt/sequence_diagram.cpp | 3 | ||||
-rw-r--r-- | ui/qt/sequence_dialog.cpp | 21 | ||||
-rw-r--r-- | ui/qt/sequence_dialog.h | 3 | ||||
-rw-r--r-- | ui/tap-sequence-analysis.c | 365 | ||||
-rw-r--r-- | ui/tap-sequence-analysis.h | 79 | ||||
-rw-r--r-- | ui/voip_calls.h | 3 |
15 files changed, 344 insertions, 462 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index bd0d085c88..e4d79c904a 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -1366,6 +1366,7 @@ libwireshark.so.0 libwireshark0 #MINVER# scsi_ssc_vals_ext@Base 1.12.0~rc1 sctp_port_to_display@Base 1.99.2 sequence_analysis_create_sai_with_addresses@Base 2.5.0 + sequence_analysis_dump_to_file@Base 2.5.0 sequence_analysis_find_by_name@Base 2.5.0 sequence_analysis_free_nodes@Base 2.5.0 sequence_analysis_get_name@Base 2.5.0 diff --git a/epan/dissectors/packet-lbmc.c b/epan/dissectors/packet-lbmc.c index 888fdeb9cb..bdf5318da2 100644 --- a/epan/dissectors/packet-lbmc.c +++ b/epan/dissectors/packet-lbmc.c @@ -27,6 +27,7 @@ #include <epan/prefs.h> #include <epan/expert.h> #include <epan/sequence_analysis.h> +#include <epan/column-info.h> #include <epan/to_str.h> #include <epan/tap.h> #include "packet-lbm.h" @@ -6084,6 +6085,7 @@ lbm_uim_seq_analysis_packet(void *ptr, packet_info *pinfo, epan_dissect_t *edt _ gchar * ctxinst2; gboolean swap_endpoints = FALSE; seq_analysis_item_t* sai; + char time_str[COL_MAX_LEN]; int rc; if ((sainfo->all_packets)||(pinfo->fd->flags.passed_dfilter==1)) @@ -6188,6 +6190,11 @@ lbm_uim_seq_analysis_packet(void *ptr, packet_info *pinfo, epan_dissect_t *edt _ epb.stream_info.dest.port, stream_info->channel); } + + /* Fill in the timestamps */ + set_fd_time(pinfo->epan, pinfo->fd, time_str); + sai->time_str = g_strdup(time_str); + sai->conv_num = (guint16)LBM_CHANNEL_ID(stream_info->channel); sai->display = TRUE; sai->line_style = 1; diff --git a/epan/sequence_analysis.c b/epan/sequence_analysis.c index 0cb4183c8f..ed52782ba0 100644 --- a/epan/sequence_analysis.c +++ b/epan/sequence_analysis.c @@ -32,6 +32,7 @@ #include "column-info.h" #include "tap.h" #include "wmem/wmem.h" +#include "wsutil/file_util.h" #define NODE_OVERFLOW MAX_NUM_NODES+1 @@ -326,6 +327,294 @@ sequence_analysis_free_nodes(seq_analysis_info_t *sainfo) sainfo->num_nodes = 0; } +/* Writing analysis to file */ +/****************************************************************************/ + +#define NODE_CHARS_WIDTH 20 +#define CONV_TIME_HEADER "Conv.| Time " +#define TIME_HEADER "|Time " +#define CONV_TIME_EMPTY_HEADER " | " +#define TIME_EMPTY_HEADER "| " +#define CONV_TIME_HEADER_LENGTH 16 +#define TIME_HEADER_LENGTH 10 + +/****************************************************************************/ +/* Adds trailing characters to complete the requested length. */ +/****************************************************************************/ + +static void enlarge_string(GString *gstr, guint32 length, char pad) { + + gsize i; + + for (i = gstr->len; i < length; i++) { + g_string_append_c(gstr, pad); + } +} + +/****************************************************************************/ +/* overwrites the characters in a string, between positions p1 and p2, with */ +/* the characters of text_to_insert */ +/* NB: it does not check that p1 and p2 fit into string */ +/****************************************************************************/ + +static void overwrite (GString *gstr, char *text_to_insert, guint32 p1, guint32 p2) { + + glong len, ins_len; + gsize pos; + gchar *ins_str = NULL; + + if (p1 == p2) + return; + + if (p1 > p2) { + pos = p2; + len = p1 - p2; + } + else{ + pos = p1; + len = p2 - p1; + } + + ins_len = g_utf8_strlen(text_to_insert, -1); + if (len > ins_len) { + len = ins_len; + } else if (len < ins_len) { +#if GLIB_CHECK_VERSION(2,30,0) + ins_str = g_utf8_substring(text_to_insert, 0, len); +#else + gchar *end = g_utf8_offset_to_pointer(text_to_insert, len); + ins_str = g_strndup(text_to_insert, end - text_to_insert); +#endif + } + + if (!ins_str) ins_str = g_strdup(text_to_insert); + + if (pos > gstr->len) + pos = gstr->len; + + g_string_erase(gstr, pos, len); + + g_string_insert(gstr, pos, ins_str); + g_free(ins_str); +} + + +gboolean +sequence_analysis_dump_to_file(const char *pathname, seq_analysis_info_t *sainfo, unsigned int first_node) +{ + guint32 i, display_items, display_nodes; + guint32 start_position, end_position, item_width, header_length; + seq_analysis_item_t *sai; + guint16 first_conv_num = 0; + gboolean several_convs = FALSE; + gboolean first_packet = TRUE; + + GString *label_string, *empty_line, *separator_line, *tmp_str, *tmp_str2; + const char *empty_header; + char src_port[8], dst_port[8]; + GList *list; + char *addr_str; + + FILE *of; + + of = ws_fopen(pathname, "w"); + if (of==NULL) { + return FALSE; + } + + display_items = 0; + list = g_queue_peek_nth_link(sainfo->items, 0); + while (list) + { + sai = (seq_analysis_item_t *)list->data; + list = g_list_next(list); + + if (!sai->display) + continue; + + display_items += 1; + if (first_packet) { + first_conv_num = sai->conv_num; + first_packet = FALSE; + } + else if (sai->conv_num != first_conv_num) { + several_convs = TRUE; + } + } + + /* if not items to display */ + if (display_items == 0) { + fclose (of); + return TRUE; + } + + label_string = g_string_new(""); + empty_line = g_string_new(""); + separator_line = g_string_new(""); + tmp_str = g_string_new(""); + tmp_str2 = g_string_new(""); + + display_nodes = sainfo->num_nodes; + + /* Write the conv. and time headers */ + if (several_convs) { + fprintf(of, CONV_TIME_HEADER); + empty_header = CONV_TIME_EMPTY_HEADER; + header_length = CONV_TIME_HEADER_LENGTH; + } + else{ + fprintf(of, TIME_HEADER); + empty_header = TIME_EMPTY_HEADER; + header_length = TIME_HEADER_LENGTH; + } + + /* Write the node names on top */ + for (i=0; i<display_nodes; i+=2) { + /* print the node identifiers */ + addr_str = address_to_display(NULL, &(sainfo->nodes[i+first_node])); + g_string_printf(label_string, "| %s", addr_str); + wmem_free(NULL, addr_str); + enlarge_string(label_string, NODE_CHARS_WIDTH*2, ' '); + fprintf(of, "%s", label_string->str); + g_string_printf(label_string, "| "); + enlarge_string(label_string, NODE_CHARS_WIDTH, ' '); + g_string_append(empty_line, label_string->str); + } + + fprintf(of, "|\n%s", empty_header); + g_string_printf(label_string, "| "); + enlarge_string(label_string, NODE_CHARS_WIDTH, ' '); + fprintf(of, "%s", label_string->str); + + /* Write the node names on top */ + for (i=1; i<display_nodes; i+=2) { + /* print the node identifiers */ + addr_str = address_to_display(NULL, &(sainfo->nodes[i+first_node])); + g_string_printf(label_string, "| %s", addr_str); + wmem_free(NULL, addr_str); + if (label_string->len < NODE_CHARS_WIDTH) + { + enlarge_string(label_string, NODE_CHARS_WIDTH, ' '); + g_string_append(label_string, "| "); + } + enlarge_string(label_string, NODE_CHARS_WIDTH*2, ' '); + fprintf(of, "%s", label_string->str); + g_string_printf(label_string, "| "); + enlarge_string(label_string, NODE_CHARS_WIDTH, ' '); + g_string_append(empty_line, label_string->str); + } + + fprintf(of, "\n"); + + g_string_append_c(empty_line, '|'); + + enlarge_string(separator_line, (guint32) empty_line->len + header_length, '-'); + + /* + * Draw the items + */ + + list = g_queue_peek_nth_link(sainfo->items, 0); + while (list) + { + sai = (seq_analysis_item_t *)list->data; + list = g_list_next(list); + + if (!sai->display) + continue; + + start_position = (sai->src_node-first_node)*NODE_CHARS_WIDTH+NODE_CHARS_WIDTH/2; + + end_position = (sai->dst_node-first_node)*NODE_CHARS_WIDTH+NODE_CHARS_WIDTH/2; + + if (start_position > end_position) { + item_width = start_position-end_position; + } + else if (start_position < end_position) { + item_width = end_position-start_position; + } + else{ /* same origin and destination address */ + end_position = start_position+NODE_CHARS_WIDTH; + item_width = NODE_CHARS_WIDTH; + } + + /* separator between conversations */ + if (sai->conv_num != first_conv_num) { + fprintf(of, "%s\n", separator_line->str); + first_conv_num = sai->conv_num; + } + + /* write the conversation number */ + if (several_convs) { + g_string_printf(label_string, "%i", sai->conv_num); + enlarge_string(label_string, 5, ' '); + fprintf(of, "%s", label_string->str); + } + + if (sai->time_str != NULL) { + g_string_printf(label_string, "|%s", sai->time_str); + enlarge_string(label_string, 10, ' '); + fprintf(of, "%s", label_string->str); + } + + /* write the frame label */ + + g_string_printf(tmp_str, "%s", empty_line->str); + overwrite(tmp_str, sai->frame_label, + start_position, + end_position + ); + fprintf(of, "%s", tmp_str->str); + + /* write the comments */ + fprintf(of, "%s\n", sai->comment); + + /* write the arrow and frame label*/ + fprintf(of, "%s", empty_header); + + g_string_printf(tmp_str, "%s", empty_line->str); + + g_string_truncate(tmp_str2, 0); + + if (start_position<end_position) { + enlarge_string(tmp_str2, item_width-2, '-'); + g_string_append_c(tmp_str2, '>'); + } + else{ + g_string_printf(tmp_str2, "<"); + enlarge_string(tmp_str2, item_width-1, '-'); + } + + overwrite(tmp_str, tmp_str2->str, + start_position, + end_position + ); + + g_snprintf(src_port, sizeof(src_port), "(%i)", sai->port_src); + g_snprintf(dst_port, sizeof(dst_port), "(%i)", sai->port_dst); + + if (start_position<end_position) { + overwrite(tmp_str, src_port, start_position-9, start_position-1); + overwrite(tmp_str, dst_port, end_position+1, end_position+9); + } + else{ + overwrite(tmp_str, src_port, start_position+1, start_position+9); + overwrite(tmp_str, dst_port, end_position-9, end_position+1); + } + + fprintf(of, "%s\n", tmp_str->str); + } + + g_string_free(label_string, TRUE); + g_string_free(empty_line, TRUE); + g_string_free(separator_line, TRUE); + g_string_free(tmp_str, TRUE); + g_string_free(tmp_str2, TRUE); + fclose (of); + return TRUE; + +} + /* * Editor modelines * diff --git a/epan/sequence_analysis.h b/epan/sequence_analysis.h index d4f5d61122..68af7f5c68 100644 --- a/epan/sequence_analysis.h +++ b/epan/sequence_analysis.h @@ -199,6 +199,16 @@ WS_DLL_PUBLIC int sequence_analysis_get_nodes(seq_analysis_info_t *sainfo); */ WS_DLL_PUBLIC void sequence_analysis_free_nodes(seq_analysis_info_t *sainfo); + +/** Write an ASCII version of the sequence diagram to a file. + * + * @param pathname Pathname of the file to write. + * @param sainfo Sequence analysis information. + * @param first_node Start drawing at this node. + * @return TRUE on success, FALSE on failure. + */ +WS_DLL_PUBLIC gboolean sequence_analysis_dump_to_file(const char *pathname, seq_analysis_info_t *sainfo, unsigned int first_node); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index e02eab1c6e..7c7ac38792 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -55,7 +55,6 @@ set(COMMON_UI_SRC tap-iax2-analysis.c tap-rtp-common.c tap-sctp-analysis.c - tap-sequence-analysis.c tap-rlc-graph.c tap-tcp-stream.c text_import.c diff --git a/ui/Makefile.am b/ui/Makefile.am index 49699c6615..9f26d78610 100644 --- a/ui/Makefile.am +++ b/ui/Makefile.am @@ -83,7 +83,6 @@ WIRESHARK_UI_SRC = \ tap-rlc-graph.c \ tap-rtp-common.c \ tap-sctp-analysis.c \ - tap-sequence-analysis.c \ tap-tcp-stream.c \ text_import.c \ time_shift.c \ @@ -136,7 +135,6 @@ WIRESHARK_UI_INCLUDES = \ tap-rtp-analysis.h \ tap-rtp-common.h \ tap-sctp-analysis.h \ - tap-sequence-analysis.h \ tap-tcp-stream.h \ text_import.h \ text_import_scanner.h \ diff --git a/ui/gtk/flow_graph.c b/ui/gtk/flow_graph.c index 5475be457b..2214bf7947 100644 --- a/ui/gtk/flow_graph.c +++ b/ui/gtk/flow_graph.c @@ -147,12 +147,21 @@ toggle_select_netsrcdst(GtkWidget *widget _U_, gpointer user_data _U_) /****************************************************************************/ static void -flow_graph_on_ok(GtkButton *button _U_, - gpointer user_data) +flow_graph_on_ok(GtkButton *button _U_, gpointer user_data) { + register_analysis_t* analysis = sequence_analysis_find_by_name(graph_analysis->name); + /* Scan for displayed packets (retap all packets) */ sequence_analysis_list_free(graph_analysis); - sequence_analysis_list_get(&cfile, graph_analysis); + + if (analysis != NULL) + { + register_tap_listener(sequence_analysis_get_tap_listener_name(analysis), graph_analysis, NULL, sequence_analysis_get_tap_flags(analysis), + NULL, sequence_analysis_get_packet_func(analysis), NULL); + + cf_retap_packets(&cfile); + remove_tap_listener(graph_analysis); + } if (graph_analysis_data->dlg.window != NULL){ /* if we still have a window */ graph_analysis_update(graph_analysis_data); /* refresh it xxx */ diff --git a/ui/gtk/graph_analysis.c b/ui/gtk/graph_analysis.c index 5662ea0755..a5f7d2cabb 100644 --- a/ui/gtk/graph_analysis.c +++ b/ui/gtk/graph_analysis.c @@ -52,6 +52,7 @@ #include "ui/last_open_dir.h" #include "ui/recent.h" #include "ui/simple_dialog.h" +#include "ui/alert_box.h" #include "ui/gtk/gtkglobals.h" #include "ui/gtk/file_dlg.h" @@ -264,10 +265,12 @@ on_save_bt_clicked (GtkWidget *button _U_, /* User gave up. */ break; } - if (sequence_analysis_dump_to_file(pathname, user_data->graph_info, &cfile, user_data->dlg.first_node)) { + if (sequence_analysis_dump_to_file(pathname, user_data->graph_info, user_data->dlg.first_node)) { /* We succeeded. */ g_free(pathname); break; + } else { + open_failure_alert_box(pathname, errno, TRUE); } /* Dump failed; let the user select another file or give up. */ diff --git a/ui/gtk/graph_analysis.h b/ui/gtk/graph_analysis.h index a22c87c46c..a715ed1944 100644 --- a/ui/gtk/graph_analysis.h +++ b/ui/gtk/graph_analysis.h @@ -32,7 +32,7 @@ #include <glib.h> #include <gtk/gtk.h> #include <epan/address.h> -#include <ui/tap-sequence-analysis.h> +#include <epan/sequence_analysis.h> /** max number of nodes to display, each node will be an IP address */ #define MAX_NUM_COL_CONV 10 diff --git a/ui/qt/sequence_diagram.cpp b/ui/qt/sequence_diagram.cpp index 3b20d0b462..a992c36803 100644 --- a/ui/qt/sequence_diagram.cpp +++ b/ui/qt/sequence_diagram.cpp @@ -22,8 +22,7 @@ #include "sequence_diagram.h" #include "epan/addr_resolv.h" - -#include "ui/tap-sequence-analysis.h" +#include "epan/sequence_analysis.h" #include <ui/qt/utils/color_utils.h> #include <ui/qt/utils/qt_ui_utils.h> diff --git a/ui/qt/sequence_dialog.cpp b/ui/qt/sequence_dialog.cpp index 786a73076d..9af0232787 100644 --- a/ui/qt/sequence_dialog.cpp +++ b/ui/qt/sequence_dialog.cpp @@ -34,6 +34,7 @@ #include "sequence_diagram.h" #include "wireshark_application.h" #include <ui/qt/utils/variant_pointer.h> +#include <ui/alert_box.h> #include <QDir> #include <QFileDialog> @@ -399,12 +400,14 @@ void SequenceDialog::on_buttonBox_accepted() } else if (extension.compare(jpeg_filter) == 0) { save_ok = ui->sequencePlot->saveJpg(file_name); } else if (extension.compare(ascii_filter) == 0 && !file_closed_ && info_->sainfo()) { - save_ok = sequence_analysis_dump_to_file(file_name.toUtf8().constData(), info_->sainfo(), cap_file_.capFile(), 0); + save_ok = sequence_analysis_dump_to_file(file_name.toUtf8().constData(), info_->sainfo(), 0); } // else error dialog? if (save_ok) { path = QDir(file_name); wsApp->setLastOpenDir(path.canonicalPath().toUtf8().constData()); + } else { + open_failure_alert_box(file_name.toUtf8().constData(), errno, TRUE); } } } @@ -420,9 +423,19 @@ void SequenceDialog::fillDiagram() } else { seq_diagram_->clearData(); sequence_analysis_list_free(info_->sainfo()); - sequence_analysis_list_get(cap_file_.capFile(), info_->sainfo()); - num_items_ = sequence_analysis_get_nodes(info_->sainfo()); - seq_diagram_->setData(info_->sainfo()); + + register_analysis_t* analysis = sequence_analysis_find_by_name(info_->sainfo()->name); + if (analysis != NULL) + { + register_tap_listener(sequence_analysis_get_tap_listener_name(analysis), info_->sainfo(), NULL, sequence_analysis_get_tap_flags(analysis), + NULL, sequence_analysis_get_packet_func(analysis), NULL); + + cf_retap_packets(cap_file_.capFile()); + remove_tap_listener(info_->sainfo()); + + num_items_ = sequence_analysis_get_nodes(info_->sainfo()); + seq_diagram_->setData(info_->sainfo()); + } } sequence_w_ = one_em_ * 15; // Arbitrary diff --git a/ui/qt/sequence_dialog.h b/ui/qt/sequence_dialog.h index 110e1f948e..c4d8caf5fb 100644 --- a/ui/qt/sequence_dialog.h +++ b/ui/qt/sequence_dialog.h @@ -29,8 +29,7 @@ #include "cfile.h" #include "epan/packet.h" - -#include "ui/tap-sequence-analysis.h" +#include "epan/sequence_analysis.h" #include <ui/qt/widgets/qcustomplot.h> #include "wireshark_dialog.h" diff --git a/ui/tap-sequence-analysis.c b/ui/tap-sequence-analysis.c deleted file mode 100644 index 6e24d64432..0000000000 --- a/ui/tap-sequence-analysis.c +++ /dev/null @@ -1,365 +0,0 @@ -/* tap-sequence-analysis.c - * Flow sequence analysis - * - * Some code from from gtk/flow_graph.c - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include "file.h" - -#include "tap-sequence-analysis.h" - -#include "epan/addr_resolv.h" -#include "epan/packet.h" -#include "epan/tap.h" - -#include "ui/alert_box.h" - -#include <wsutil/file_util.h> - -#define NODE_CHARS_WIDTH 20 -#define CONV_TIME_HEADER "Conv.| Time " -#define TIME_HEADER "|Time " -#define CONV_TIME_EMPTY_HEADER " | " -#define TIME_EMPTY_HEADER "| " -#define CONV_TIME_HEADER_LENGTH 16 -#define TIME_HEADER_LENGTH 10 - -void -sequence_analysis_list_get(capture_file *cf, seq_analysis_info_t *sainfo) -{ - register_analysis_t* analysis = NULL; - - if (!cf || !sainfo) - return; - - analysis = sequence_analysis_find_by_name(sainfo->name); - if (analysis == NULL) - return; - - register_tap_listener(sequence_analysis_get_tap_listener_name(analysis), sainfo, NULL, sequence_analysis_get_tap_flags(analysis), - NULL, sequence_analysis_get_packet_func(analysis), NULL); - - cf_retap_packets(cf); - remove_tap_listener(sainfo); - - /* SEQ_ANALYSIS_DEBUG("%d items", g_queue_get_length(sainfo->items)); */ -} - -/****************************************************************************/ -/* Adds trailing characters to complete the requested length. */ -/****************************************************************************/ - -static void enlarge_string(GString *gstr, guint32 length, char pad) { - - gsize i; - - for (i = gstr->len; i < length; i++) { - g_string_append_c(gstr, pad); - } -} - -/****************************************************************************/ -/* overwrites the characters in a string, between positions p1 and p2, with */ -/* the characters of text_to_insert */ -/* NB: it does not check that p1 and p2 fit into string */ -/****************************************************************************/ - -static void overwrite (GString *gstr, char *text_to_insert, guint32 p1, guint32 p2) { - - glong len, ins_len; - gsize pos; - gchar *ins_str = NULL; - - if (p1 == p2) - return; - - if (p1 > p2) { - pos = p2; - len = p1 - p2; - } - else{ - pos = p1; - len = p2 - p1; - } - - ins_len = g_utf8_strlen(text_to_insert, -1); - if (len > ins_len) { - len = ins_len; - } else if (len < ins_len) { -#if GLIB_CHECK_VERSION(2,30,0) - ins_str = g_utf8_substring(text_to_insert, 0, len); -#else - gchar *end = g_utf8_offset_to_pointer(text_to_insert, len); - ins_str = g_strndup(text_to_insert, end - text_to_insert); -#endif - } - - if (!ins_str) ins_str = g_strdup(text_to_insert); - - if (pos > gstr->len) - pos = gstr->len; - - g_string_erase(gstr, pos, len); - - g_string_insert(gstr, pos, ins_str); - g_free(ins_str); -} - -/****************************************************************************/ -gboolean -sequence_analysis_dump_to_file(const char *pathname, seq_analysis_info_t *sainfo, capture_file *cf, unsigned int first_node) -{ - guint32 i, display_items, display_nodes; - guint32 start_position, end_position, item_width, header_length; - seq_analysis_item_t *sai; - frame_data *fd; - guint16 first_conv_num = 0; - gboolean several_convs = FALSE; - gboolean first_packet = TRUE; - - GString *label_string, *empty_line, *separator_line, *tmp_str, *tmp_str2; - const char *empty_header; - char src_port[8], dst_port[8]; - gchar *time_str; - GList *list; - char *addr_str; - - FILE *of; - - of = ws_fopen(pathname, "w"); - if (of==NULL) { - open_failure_alert_box(pathname, errno, TRUE); - return FALSE; - } - - time_str = (gchar *)g_malloc(COL_MAX_LEN); - label_string = g_string_new(""); - empty_line = g_string_new(""); - separator_line = g_string_new(""); - tmp_str = g_string_new(""); - tmp_str2 = g_string_new(""); - - display_items = 0; - list = g_queue_peek_nth_link(sainfo->items, 0); - while (list) - { - sai = (seq_analysis_item_t *)list->data; - list = g_list_next(list); - - if (!sai->display) - continue; - - display_items += 1; - if (first_packet) { - first_conv_num = sai->conv_num; - first_packet = FALSE; - } - else if (sai->conv_num != first_conv_num) { - several_convs = TRUE; - } - } - - /* if not items to display */ - if (display_items == 0) - goto exit; - - display_nodes = sainfo->num_nodes; - - /* Write the conv. and time headers */ - if (several_convs) { - fprintf(of, CONV_TIME_HEADER); - empty_header = CONV_TIME_EMPTY_HEADER; - header_length = CONV_TIME_HEADER_LENGTH; - } - else{ - fprintf(of, TIME_HEADER); - empty_header = TIME_EMPTY_HEADER; - header_length = TIME_HEADER_LENGTH; - } - - /* Write the node names on top */ - for (i=0; i<display_nodes; i+=2) { - /* print the node identifiers */ - addr_str = address_to_display(NULL, &(sainfo->nodes[i+first_node])); - g_string_printf(label_string, "| %s", addr_str); - wmem_free(NULL, addr_str); - enlarge_string(label_string, NODE_CHARS_WIDTH*2, ' '); - fprintf(of, "%s", label_string->str); - g_string_printf(label_string, "| "); - enlarge_string(label_string, NODE_CHARS_WIDTH, ' '); - g_string_append(empty_line, label_string->str); - } - - fprintf(of, "|\n%s", empty_header); - g_string_printf(label_string, "| "); - enlarge_string(label_string, NODE_CHARS_WIDTH, ' '); - fprintf(of, "%s", label_string->str); - - /* Write the node names on top */ - for (i=1; i<display_nodes; i+=2) { - /* print the node identifiers */ - addr_str = address_to_display(NULL, &(sainfo->nodes[i+first_node])); - g_string_printf(label_string, "| %s", addr_str); - wmem_free(NULL, addr_str); - if (label_string->len < NODE_CHARS_WIDTH) - { - enlarge_string(label_string, NODE_CHARS_WIDTH, ' '); - g_string_append(label_string, "| "); - } - enlarge_string(label_string, NODE_CHARS_WIDTH*2, ' '); - fprintf(of, "%s", label_string->str); - g_string_printf(label_string, "| "); - enlarge_string(label_string, NODE_CHARS_WIDTH, ' '); - g_string_append(empty_line, label_string->str); - } - - fprintf(of, "\n"); - - g_string_append_c(empty_line, '|'); - - enlarge_string(separator_line, (guint32) empty_line->len + header_length, '-'); - - /* - * Draw the items - */ - - list = g_queue_peek_nth_link(sainfo->items, 0); - while (list) - { - sai = (seq_analysis_item_t *)list->data; - list = g_list_next(list); - - if (!sai->display) - continue; - - start_position = (sai->src_node-first_node)*NODE_CHARS_WIDTH+NODE_CHARS_WIDTH/2; - - end_position = (sai->dst_node-first_node)*NODE_CHARS_WIDTH+NODE_CHARS_WIDTH/2; - - if (start_position > end_position) { - item_width = start_position-end_position; - } - else if (start_position < end_position) { - item_width = end_position-start_position; - } - else{ /* same origin and destination address */ - end_position = start_position+NODE_CHARS_WIDTH; - item_width = NODE_CHARS_WIDTH; - } - - /* separator between conversations */ - if (sai->conv_num != first_conv_num) { - fprintf(of, "%s\n", separator_line->str); - first_conv_num = sai->conv_num; - } - - /* write the conversation number */ - if (several_convs) { - g_string_printf(label_string, "%i", sai->conv_num); - enlarge_string(label_string, 5, ' '); - fprintf(of, "%s", label_string->str); - } - - fd = frame_data_sequence_find(cf->frames, sai->frame_number); -#if 0 - /* write the time */ - g_string_printf(label_string, "|%.3f", nstime_to_sec(&fd->rel_ts)); -#endif - /* Write the time, using the same format as in the time col */ - set_fd_time(cf->epan, fd, time_str); - g_string_printf(label_string, "|%s", time_str); - enlarge_string(label_string, 10, ' '); - fprintf(of, "%s", label_string->str); - - /* write the frame label */ - - g_string_printf(tmp_str, "%s", empty_line->str); - overwrite(tmp_str, sai->frame_label, - start_position, - end_position - ); - fprintf(of, "%s", tmp_str->str); - - /* write the comments */ - fprintf(of, "%s\n", sai->comment); - - /* write the arrow and frame label*/ - fprintf(of, "%s", empty_header); - - g_string_printf(tmp_str, "%s", empty_line->str); - - g_string_truncate(tmp_str2, 0); - - if (start_position<end_position) { - enlarge_string(tmp_str2, item_width-2, '-'); - g_string_append_c(tmp_str2, '>'); - } - else{ - g_string_printf(tmp_str2, "<"); - enlarge_string(tmp_str2, item_width-1, '-'); - } - - overwrite(tmp_str, tmp_str2->str, - start_position, - end_position - ); - - g_snprintf(src_port, sizeof(src_port), "(%i)", sai->port_src); - g_snprintf(dst_port, sizeof(dst_port), "(%i)", sai->port_dst); - - if (start_position<end_position) { - overwrite(tmp_str, src_port, start_position-9, start_position-1); - overwrite(tmp_str, dst_port, end_position+1, end_position+9); - } - else{ - overwrite(tmp_str, src_port, start_position+1, start_position+9); - overwrite(tmp_str, dst_port, end_position-9, end_position+1); - } - - fprintf(of, "%s\n", tmp_str->str); - } - -exit: - g_string_free(label_string, TRUE); - g_string_free(empty_line, TRUE); - g_string_free(separator_line, TRUE); - g_string_free(tmp_str, TRUE); - g_string_free(tmp_str2, TRUE); - g_free(time_str); - fclose (of); - return TRUE; - -} - -/* - * Editor modelines - * - * Local Variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * ex: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/ui/tap-sequence-analysis.h b/ui/tap-sequence-analysis.h deleted file mode 100644 index f6d6d3267a..0000000000 --- a/ui/tap-sequence-analysis.h +++ /dev/null @@ -1,79 +0,0 @@ -/* tap-sequence-analysis.h - * Flow sequence analysis - * - * Copied from gtk/graph_analysis.h - * - * Copyright 2004, Verso Technologies Inc. - * By Alejandro Vaquero <alejandrovaquero@yahoo.com> - * - * based on rtp_analysis.c and io_stat - * - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __TAP_SEQUENCE_ANALYSIS_H__ -#define __TAP_SEQUENCE_ANALYSIS_H__ - -#include <glib.h> - -#include "cfile.h" -#include "epan/address.h" - -#include <epan/sequence_analysis.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** Fill in the segment list for sequence analysis - * - * @param cf Capture file to scan - * @param sainfo Sequence analysis information. A valid type must be set. - */ -void sequence_analysis_list_get(capture_file *cf, seq_analysis_info_t *sainfo); - -/** Write an ASCII version of the sequence diagram to a file. - * - * @param pathname Pathname of the file to write. - * @param sainfo Sequence analysis information. - * @param cf Capture file associated with the diagram. - * @param first_node Start drawing at this node. - * @return TRUE on success, FALSE on failure. - */ -gboolean sequence_analysis_dump_to_file(const char *pathname, seq_analysis_info_t *sainfo, capture_file *cf, unsigned int first_node); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __TAP_SEQUENCE_ANALYSIS_H__ */ - -/* - * Editor modelines - * - * Local Variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * ex: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/ui/voip_calls.h b/ui/voip_calls.h index 193d0dd6c7..aed1facbbb 100644 --- a/ui/voip_calls.h +++ b/ui/voip_calls.h @@ -51,8 +51,7 @@ extern "C" { #include "epan/guid-utils.h" #include "epan/tap.h" #include "epan/tap-voip.h" - -#include "ui/tap-sequence-analysis.h" +#include "epan/sequence_analysis.h" /****************************************************************************/ extern const char *voip_call_state_name[8]; |