2015-02-11 23:00:27 +00:00
|
|
|
/* packet_dialog.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2017-12-07 16:15:30 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2015-02-11 23:00:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "packet_dialog.h"
|
2015-06-25 16:17:03 +00:00
|
|
|
#include <ui_packet_dialog.h>
|
2015-02-11 23:00:27 +00:00
|
|
|
|
2015-02-12 23:35:59 +00:00
|
|
|
#include "file.h"
|
|
|
|
|
2015-02-11 23:00:27 +00:00
|
|
|
#include "epan/column.h"
|
|
|
|
#include "epan/ftypes/ftypes.h"
|
|
|
|
|
|
|
|
#include "frame_tvbuff.h"
|
|
|
|
|
2015-10-04 17:10:29 +00:00
|
|
|
#include <wsutil/utf8_entities.h>
|
2015-02-12 18:17:05 +00:00
|
|
|
|
2015-02-11 23:00:27 +00:00
|
|
|
#include "byte_view_tab.h"
|
|
|
|
#include "proto_tree.h"
|
|
|
|
#include "wireshark_application.h"
|
|
|
|
|
2017-10-30 12:58:28 +00:00
|
|
|
#include <ui/qt/utils/field_information.h>
|
2015-02-11 23:00:27 +00:00
|
|
|
#include <QTreeWidgetItemIterator>
|
|
|
|
|
|
|
|
// To do:
|
|
|
|
// - Copy over experimental packet editing code.
|
|
|
|
// - Fix ElidedText width.
|
|
|
|
|
2015-03-02 04:01:17 +00:00
|
|
|
PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata) :
|
2015-02-11 23:00:27 +00:00
|
|
|
WiresharkDialog(parent, cf),
|
|
|
|
ui(new Ui::PacketDialog),
|
|
|
|
packet_data_(NULL)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2016-02-28 18:23:20 +00:00
|
|
|
loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
|
2015-02-12 18:17:05 +00:00
|
|
|
ui->hintLabel->setSmallText();
|
2015-02-11 23:00:27 +00:00
|
|
|
|
|
|
|
setWindowSubtitle(tr("Packet %1").arg(fdata->num));
|
|
|
|
|
2016-06-29 23:12:12 +00:00
|
|
|
if (!cf_read_record(cap_file_.capFile(), fdata)) reject();
|
|
|
|
|
2015-02-11 23:00:27 +00:00
|
|
|
phdr_ = cap_file_.capFile()->phdr;
|
|
|
|
packet_data_ = (guint8 *) g_memdup(ws_buffer_start_ptr(&(cap_file_.capFile()->buf)), fdata->cap_len);
|
|
|
|
|
|
|
|
/* proto tree, visible. We need a proto tree if there's custom columns */
|
|
|
|
epan_dissect_init(&edt_, cap_file_.capFile()->epan, TRUE, TRUE);
|
|
|
|
col_custom_prime_edt(&edt_, &(cap_file_.capFile()->cinfo));
|
|
|
|
|
|
|
|
epan_dissect_run(&edt_, cap_file_.capFile()->cd_t, &phdr_,
|
2017-12-08 08:30:55 +00:00
|
|
|
frame_tvbuff_new(&cap_file_.capFile()->provider, fdata, packet_data_),
|
2015-02-11 23:00:27 +00:00
|
|
|
fdata, &(cap_file_.capFile()->cinfo));
|
|
|
|
epan_dissect_fill_in_columns(&edt_, TRUE, TRUE);
|
|
|
|
|
|
|
|
proto_tree_ = new ProtoTree(ui->packetSplitter);
|
2017-12-07 16:15:30 +00:00
|
|
|
proto_tree_->setRootNode(edt_.tree);
|
2015-02-11 23:00:27 +00:00
|
|
|
|
|
|
|
byte_view_tab_ = new ByteViewTab(ui->packetSplitter);
|
|
|
|
byte_view_tab_->setCaptureFile(cap_file_.capFile());
|
2017-11-12 10:29:13 +00:00
|
|
|
byte_view_tab_->selectedFrameChanged(0);
|
2015-02-11 23:00:27 +00:00
|
|
|
|
2014-12-13 00:51:40 +00:00
|
|
|
ui->packetSplitter->setStretchFactor(1, 0);
|
2015-02-11 23:00:27 +00:00
|
|
|
|
|
|
|
QStringList col_parts;
|
|
|
|
for (int i = 0; i < cap_file_.capFile()->cinfo.num_cols; ++i) {
|
2015-02-12 18:17:05 +00:00
|
|
|
// ElidedLabel doesn't support rich text / HTML
|
|
|
|
col_parts << QString("%1: %2")
|
|
|
|
.arg(get_column_title(i))
|
2015-06-27 03:00:33 +00:00
|
|
|
.arg(cap_file_.capFile()->cinfo.columns[i].col_data);
|
2015-02-11 23:00:27 +00:00
|
|
|
}
|
2015-02-12 18:17:05 +00:00
|
|
|
col_info_ = col_parts.join(" " UTF8_MIDDLE_DOT " ");
|
2017-10-25 13:39:35 +00:00
|
|
|
|
|
|
|
ui->hintLabel->setText(col_info_);
|
2015-02-11 23:00:27 +00:00
|
|
|
|
2017-10-30 12:58:28 +00:00
|
|
|
connect(wsApp, SIGNAL(zoomMonospaceFont(QFont)),
|
2015-02-11 23:00:27 +00:00
|
|
|
proto_tree_, SLOT(setMonospaceFont(QFont)));
|
2017-10-30 12:58:28 +00:00
|
|
|
|
|
|
|
connect(byte_view_tab_, SIGNAL(fieldSelected(FieldInformation *)),
|
|
|
|
proto_tree_, SLOT(selectedFieldChanged(FieldInformation *)));
|
|
|
|
connect(proto_tree_, SIGNAL(fieldSelected(FieldInformation *)),
|
|
|
|
byte_view_tab_, SLOT(selectedFieldChanged(FieldInformation *)));
|
|
|
|
|
|
|
|
connect(byte_view_tab_, SIGNAL(fieldHighlight(FieldInformation *)),
|
|
|
|
this, SLOT(setHintText(FieldInformation *)));
|
|
|
|
|
2015-02-11 23:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PacketDialog::~PacketDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
epan_dissect_cleanup(&edt_);
|
|
|
|
g_free(packet_data_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketDialog::captureFileClosing()
|
|
|
|
{
|
2015-05-22 21:01:31 +00:00
|
|
|
QString closed_title = tr("[%1 closed] " UTF8_MIDDLE_DOT " %2")
|
|
|
|
.arg(cap_file_.fileName())
|
|
|
|
.arg(col_info_);
|
2017-10-25 13:39:35 +00:00
|
|
|
ui->hintLabel->setText(closed_title);
|
2015-02-11 23:00:27 +00:00
|
|
|
WiresharkDialog::captureFileClosing();
|
|
|
|
}
|
|
|
|
|
2017-10-30 12:58:28 +00:00
|
|
|
void PacketDialog::on_buttonBox_helpRequested()
|
2015-02-11 23:00:27 +00:00
|
|
|
{
|
2017-10-30 12:58:28 +00:00
|
|
|
wsApp->helpTopicAction(HELP_NEW_PACKET_DIALOG);
|
2015-02-11 23:00:27 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 12:58:28 +00:00
|
|
|
void PacketDialog::setHintText(FieldInformation * finfo)
|
2015-02-11 23:00:27 +00:00
|
|
|
{
|
2017-10-30 12:58:28 +00:00
|
|
|
QString hint;
|
|
|
|
|
|
|
|
if ( finfo )
|
|
|
|
{
|
|
|
|
FieldInformation::Position pos = finfo->position();
|
|
|
|
QString field_str;
|
|
|
|
|
|
|
|
if (pos.length < 2) {
|
|
|
|
hint = QString(tr("Byte %1")).arg(pos.start);
|
|
|
|
} else {
|
|
|
|
hint = QString(tr("Bytes %1-%2")).arg(pos.start).arg(pos.start + pos.length - 1);
|
|
|
|
}
|
|
|
|
hint += QString(": %1 (%2)")
|
|
|
|
.arg(finfo->headerInfo().name)
|
|
|
|
.arg(finfo->headerInfo().abbreviation);
|
|
|
|
}
|
|
|
|
ui->hintLabel->setText(hint);
|
2015-02-11 23:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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:
|
|
|
|
*/
|