nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* conversation_hash_tables_dialog.cpp |
2 | * |
||
3 | * Wireshark - Network traffic analyzer |
||
4 | * By Gerald Combs <gerald@wireshark.org> |
||
5 | * Copyright 1998 Gerald Combs |
||
6 | * |
||
7 | * This program is free software; you can redistribute it and/or |
||
8 | * modify it under the terms of the GNU General Public License |
||
9 | * as published by the Free Software Foundation; either version 2 |
||
10 | * of the License, or (at your option) any later version. |
||
11 | * |
||
12 | * This program is distributed in the hope that it will be useful, |
||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
15 | * GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License |
||
18 | * along with this program; if not, write to the Free Software |
||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
20 | */ |
||
21 | |||
22 | #include "conversation_hash_tables_dialog.h" |
||
23 | #include <ui_conversation_hash_tables_dialog.h> |
||
24 | |||
25 | #include "config.h" |
||
26 | |||
27 | #include <glib.h> |
||
28 | |||
29 | #include <epan/conversation.h> |
||
30 | #include <epan/conversation_debug.h> |
||
31 | |||
32 | #include "qt_ui_utils.h" |
||
33 | #include "wireshark_application.h" |
||
34 | |||
35 | ConversationHashTablesDialog::ConversationHashTablesDialog(QWidget *parent) : |
||
36 | GeometryStateDialog(parent), |
||
37 | ui(new Ui::ConversationHashTablesDialog) |
||
38 | { |
||
39 | ui->setupUi(this); |
||
40 | if (parent) loadGeometry(parent->width() * 3 / 4, parent->height() * 3 / 4); |
||
41 | |||
42 | setWindowTitle(wsApp->windowTitleString(tr("Dissector Tables"))); |
||
43 | |||
44 | QString html; |
||
45 | |||
46 | html += "<h3>Conversation Hash Tables</h3>\n"; |
||
47 | |||
48 | html += hashTableToHtmlTable("conversation_hashtable_exact", get_conversation_hashtable_exact()); |
||
49 | html += hashTableToHtmlTable("conversation_hashtable_no_addr2", get_conversation_hashtable_no_addr2()); |
||
50 | html += hashTableToHtmlTable("conversation_hashtable_no_port2", get_conversation_hashtable_no_port2()); |
||
51 | html += hashTableToHtmlTable("conversation_hashtable_no_addr2_or_port2", get_conversation_hashtable_no_addr2_or_port2()); |
||
52 | |||
53 | ui->conversationTextEdit->setHtml(html); |
||
54 | } |
||
55 | |||
56 | ConversationHashTablesDialog::~ConversationHashTablesDialog() |
||
57 | { |
||
58 | delete ui; |
||
59 | } |
||
60 | |||
61 | const QString ConversationHashTablesDialog::hashTableToHtmlTable(const QString table_name, struct _GHashTable *hash_table) |
||
62 | { |
||
63 | GList *conversation_keys = NULL; |
||
64 | if (hash_table) conversation_keys = g_hash_table_get_keys(hash_table); |
||
65 | int num_keys = g_list_length(conversation_keys); |
||
66 | |||
67 | QString html_table = QString("<p>%1, %2 entries</p>").arg(table_name).arg(num_keys); |
||
68 | if (num_keys < 1) return html_table; |
||
69 | |||
70 | int one_em = fontMetrics().height(); |
||
71 | html_table += QString("<table cellpadding=\"%1\">\n").arg(one_em / 4); |
||
72 | |||
73 | html_table += "<tr><th align=\"left\">Address 1</th><th align=\"left\">Port 1</th><th align=\"left\">Address 2</th><th align=\"left\">Port 2</th></tr>\n"; |
||
74 | |||
75 | // XXX Add a column for the hash value. |
||
76 | for (GList *ck_entry = conversation_keys; ck_entry; ck_entry = g_list_next(ck_entry)) { |
||
77 | const conversation_key *conv_key = (conversation_key *) ck_entry->data; |
||
78 | html_table += QString("<tr><td>%1</td><td>%2</td><td>%3</td><td>%4</td></tr>\n") |
||
79 | .arg(address_to_qstring(&conv_key->addr1)) |
||
80 | .arg(conv_key->port1) |
||
81 | .arg(address_to_qstring(&conv_key->addr2)) |
||
82 | .arg(conv_key->port2); |
||
83 | } |
||
84 | html_table += "</table>\n"; |
||
85 | return html_table; |
||
86 | } |
||
87 | |||
88 | /* |
||
89 | * Editor modelines |
||
90 | * |
||
91 | * Local Variables: |
||
92 | * c-basic-offset: 4 |
||
93 | * tab-width: 8 |
||
94 | * indent-tabs-mode: nil |
||
95 | * End: |
||
96 | * |
||
97 | * ex: set shiftwidth=4 tabstop=8 expandtab: |
||
98 | * :indentSize=4:tabSize=8:noTabs=true: |
||
99 | */ |