From e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 22:34:10 +0200 Subject: Adding upstream version 4.2.2. Signed-off-by: Daniel Baumann --- ui/qt/conversation_hash_tables_dialog.cpp | 147 ++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 ui/qt/conversation_hash_tables_dialog.cpp (limited to 'ui/qt/conversation_hash_tables_dialog.cpp') diff --git a/ui/qt/conversation_hash_tables_dialog.cpp b/ui/qt/conversation_hash_tables_dialog.cpp new file mode 100644 index 00000000..cc699dae --- /dev/null +++ b/ui/qt/conversation_hash_tables_dialog.cpp @@ -0,0 +1,147 @@ +/* conversation_hash_tables_dialog.cpp + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "conversation_hash_tables_dialog.h" +#include + +#include "config.h" + +#include + +#include +#include + +#include +#include "main_application.h" + +static void +fill_named_table(gpointer key, gpointer value _U_, gpointer user_data) +{ + const conversation_element_t *elements = static_cast(key); + QString* html_table = static_cast(user_data); + + if (!elements || !html_table) { + return; + } + + if (html_table->isEmpty()) { + html_table->append(""); + int addr_count = 1; + int port_count = 1; + int string_count = 1; + int uint_count = 1; + int uint64_count = 1; + int int_count = 1; + for (const conversation_element_t *cur_el = elements; ; cur_el++) { + QString title; + switch (cur_el->type) { + case CE_ADDRESS: + title = QString("Address %1").arg(addr_count++); + break; + case CE_PORT: + title = QString("Port %1").arg(port_count++); + break; + case CE_STRING: + title = QString("String %1").arg(string_count++); + break; + case CE_UINT: + title = QString("UInt %1").arg(uint_count++); + break; + case CE_UINT64: + title = QString("UInt64 %1").arg(uint64_count++); + break; + case CE_INT: + title = QString("Int %1").arg(int_count++); + break; + case CE_CONVERSATION_TYPE: + html_table->append(QString("Endpoint")); + goto title_done; + break; + } + html_table->append(QString("%1").arg(title)); + } +title_done: + html_table->append("\n"); + } + + html_table->append(""); + + for (const conversation_element_t *cur_el = elements; ; cur_el++) { + QString val; + switch (cur_el->type) { + case CE_ADDRESS: + val = address_to_qstring(&cur_el->addr_val); + break; + case CE_PORT: + val = QString::number(cur_el->port_val); + break; + case CE_STRING: + val = cur_el->str_val; + break; + case CE_UINT: + val = QString::number(cur_el->uint_val); + break; + case CE_UINT64: + val = QString::number(cur_el->uint64_val); + break; + case CE_INT: + val = QString::number(cur_el->int_val); + break; + case CE_CONVERSATION_TYPE: + html_table->append(QString("%1").arg(QString::number(cur_el->conversation_type_val))); + goto val_done; + break; + } + html_table->append(QString("%1").arg(val)); + } +val_done: + + html_table->append("\n"); +} + +ConversationHashTablesDialog::ConversationHashTablesDialog(QWidget *parent) : + GeometryStateDialog(parent), + ui(new Ui::ConversationHashTablesDialog) +{ + ui->setupUi(this); + if (parent) loadGeometry(parent->width() * 3 / 4, parent->height() * 3 / 4); + setAttribute(Qt::WA_DeleteOnClose, true); + setWindowTitle(mainApp->windowTitleString(tr("Conversation Hash Tables"))); + + QString html; + + html += "

Conversation Hash Tables

\n"; + + wmem_map_t *conversation_tables = get_conversation_hashtables(); + wmem_list_t *table_names = wmem_map_get_keys(NULL, conversation_tables); + for (wmem_list_frame_t *cur_frame = wmem_list_head(table_names); cur_frame; cur_frame = wmem_list_frame_next(cur_frame)) + { + const char *table_name = static_cast(wmem_list_frame_data(cur_frame)); + wmem_map_t *table = static_cast(wmem_map_lookup(conversation_tables, table_name)); + + if (!table) { + html += QString("

%1, Error: table not found

\n").arg(table_name); + continue; + } + + html += QString("

%1, %2 entries

\n").arg(table_name).arg(wmem_map_size(table)); + QString html_table; + html += "\n"; + wmem_map_foreach(table, fill_named_table, &html_table); + html += html_table; + html += "
\n"; + } + wmem_destroy_list(table_names); + ui->conversationTextEdit->setHtml(html); +} + +ConversationHashTablesDialog::~ConversationHashTablesDialog() +{ + delete ui; +} -- cgit v1.2.3