1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/* conversation_dialog.cpp
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "conversation_dialog.h"
#include <epan/prefs.h>
#include <epan/to_str.h>
#include <epan/dissectors/packet-tcp.h>
#include "ui/recent.h"
#include "ui/tap-tcp-stream.h"
#include "wsutil/str_util.h"
#include <ui/qt/utils/qt_ui_utils.h>
#include <ui/qt/models/timeline_delegate.h>
#include <ui/qt/models/atap_data_model.h>
#include <ui/qt/widgets/traffic_tab.h>
#include <ui/qt/widgets/traffic_types_list.h>
#include "main_application.h"
#include <QCheckBox>
#include <QDateTime>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QString>
// To do:
// - https://gitlab.com/wireshark/wireshark/-/issues/6727
// - Wide last column?
// - Improper wildcard handling https://gitlab.com/wireshark/wireshark/-/issues/8010
// - TShark consolidation https://gitlab.com/wireshark/wireshark/-/issues/6310
// - Display filter entry?
// - Add follow, copy & graph actions to context menu.
// Bugs:
// - Slow for large numbers of items.
// - Name resolution doesn't do anything if its preference is disabled.
// Fixed bugs:
// - Friendly unit displays https://gitlab.com/wireshark/wireshark/-/issues/9231
// - Misleading bps calculation https://gitlab.com/wireshark/wireshark/-/issues/8703
// - Show Absolute time in conversation tables https://gitlab.com/wireshark/wireshark/-/issues/11618
// - The value of 'Rel start' and 'Duration' in "Conversations" no need too precise https://gitlab.com/wireshark/wireshark/-/issues/12803
static const QString table_name_ = QObject::tr("Conversation");
static ATapDataModel * createModel(int protoId, QString filter)
{
return new ConversationDataModel(protoId, filter);
}
static QAbstractItemDelegate * createDelegate(QWidget * parent)
{
TimelineDelegate * delegate = new TimelineDelegate(parent);
delegate->setDataRole(ATapDataModel::TIMELINE_DATA);
return delegate;
}
ConversationDialog::ConversationDialog(QWidget &parent, CaptureFile &cf) :
TrafficTableDialog(parent, cf, table_name_),
tcp_graph_requested_(false)
{
trafficList()->setProtocolInfo(table_name_, &(recent.conversation_tabs));
trafficTab()->setProtocolInfo(table_name_, trafficList(), &(recent.conversation_tabs_columns), &createModel);
trafficTab()->setDelegate(&createDelegate);
trafficTab()->setDelegate(&createDelegate);
trafficTab()->setFilter(cf.displayFilter());
connect(trafficTab(), &TrafficTab::filterAction, this, &ConversationDialog::filterAction);
connect(trafficTab()->tabBar(), &QTabBar::currentChanged, this, &ConversationDialog::tabChanged);
connect(trafficTab(), &TrafficTab::tabDataChanged, this, &ConversationDialog::tabChanged);
follow_bt_ = buttonBox()->addButton(tr("Follow Stream…"), QDialogButtonBox::ActionRole);
follow_bt_->setToolTip(tr("Follow a TCP or UDP stream."));
connect(follow_bt_, SIGNAL(clicked()), this, SLOT(followStream()));
graph_bt_ = buttonBox()->addButton(tr("Graph…"), QDialogButtonBox::ActionRole);
graph_bt_->setToolTip(tr("Graph a TCP conversation."));
connect(graph_bt_, SIGNAL(clicked()), this, SLOT(graphTcp()));
connect(mainApp->mainWindow(), SIGNAL(displayFilterSuccess(bool)),
this, SLOT(displayFilterSuccess(bool)));
absoluteTimeCheckBox()->show();
updateWidgets();
}
void ConversationDialog::captureFileClosing()
{
trafficTab()->disableTap();
displayFilterCheckBox()->setEnabled(false);
follow_bt_->setEnabled(false);
graph_bt_->setEnabled(false);
TrafficTableDialog::captureFileClosing();
}
void ConversationDialog::followStream()
{
if (file_closed_)
return;
QVariant protoIdData = trafficTab()->currentItemData(ATapDataModel::PROTO_ID);
if (protoIdData.isNull())
return;
int protoId = protoIdData.toInt();
if (get_follow_by_proto_id(protoId) == nullptr)
return;
int convId = trafficTab()->currentItemData(ATapDataModel::CONVERSATION_ID).toInt();
// ATapDataModel doesn't support a substream ID (XXX: yet), so set it to a
// dummy value.
emit openFollowStreamDialog(protoId, convId, 0);
}
void ConversationDialog::graphTcp()
{
if (file_closed_)
return;
int endpointType = trafficTab()->currentItemData(ATapDataModel::ENDPOINT_DATATYPE).toInt();
if (endpointType != CONVERSATION_TCP)
return;
int convId = trafficTab()->currentItemData(ATapDataModel::CONVERSATION_ID).toInt();
// XXX The GTK+ code opens the TCP Stream dialog. We might want
// to open the I/O Graphs dialog instead.
QString filter = QString("tcp.stream eq %1").arg(convId);
tcp_graph_requested_ = true;
// Apply the filter for this conversation. When the filter is active, we
// can draw the TCP graph.
emit filterAction(filter, FilterAction::ActionApply, FilterAction::ActionTypePlain);
}
void ConversationDialog::tabChanged(int)
{
bool follow = false;
bool graph = false;
if (!file_closed_) {
QVariant proto_id = trafficTab()->currentItemData(ATapDataModel::PROTO_ID);
if (!proto_id.isNull()) {
follow = (get_follow_by_proto_id(proto_id.toInt()) != nullptr);
}
int endpointType = trafficTab()->currentItemData(ATapDataModel::ENDPOINT_DATATYPE).toInt();
switch(endpointType) {
case CONVERSATION_TCP:
graph = true;
break;
}
}
follow_bt_->setEnabled(follow);
graph_bt_->setEnabled(graph);
TrafficTableDialog::currentTabChanged();
}
void ConversationDialog::on_buttonBox_helpRequested()
{
mainApp->helpTopicAction(HELP_STATS_CONVERSATIONS_DIALOG);
}
void ConversationDialog::displayFilterSuccess(bool success)
{
if (tcp_graph_requested_) {
if (success) {
// The display filter was applied successfully, i.e. the current
// packet is now part of our selected tcp conversation.
openTcpStreamGraph(GRAPH_TSEQ_TCPTRACE);
}
tcp_graph_requested_ = false;
}
}
void init_conversation_table(struct register_ct* ct, const char *filter)
{
mainApp->emitStatCommandSignal("Conversations", filter, GINT_TO_POINTER(get_conversation_proto_id(ct)));
}
|